Implement a class Clock whose get_hours and get_minutes member functions return the current time at your location. To get the current time, use the following code, which requires that you include the header: time_t current_time = time(0);tm* local_time = localtime(¤t_time);int hours = local_time->tm_hour;int minutes = local_time->tm_min; Also provide a get_time member function that returns a string with the hours and minutes by calling the get_hours and get_minutes functions. Provide a derived class WorldClock whose constructor accepts a time offset. For example, if you live in California, a new WorldClock(3) should show the time in New York, three time zones ahead. Which member functions did you override? (You should not override get_time.).c++
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Implement a class Clock whose get_hours and get_minutes member functions return the current time at your location. To get the current time, use the following code, which requires that you include the <ctime> header:
time_t current_time = time(0);tm* local_time = localtime(¤t_time);int hours = local_time->tm_hour;int minutes = local_time->tm_min;
Also provide a get_time member function that returns a string with the hours and minutes by calling the get_hours and get_minutes functions. Provide a derived class WorldClock whose constructor accepts a time offset. For example, if you live in California, a new WorldClock(3) should show the time in New York, three time zones ahead. Which member functions did you override? (You should not override get_time.).c++
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images