Create a class MyTime which has the datamembers as follows: 1. hour: integer (1 to 12) 2. minute: integer (0 to 59) 3. second: integer (0 to 59) 4. pm: bool variable. True means PM time and false means AM time. Implement a default constructor, a parameterized constructor and a copy constructor. Write set and get functions for all the four members of the class. Overload these operators: 1. Extraction operator >> : Prompt the user for hours, minutes, seconds and for am/pm and initialize the structure. Left operand istream object and right operand MyTime 2. Assignment = : Assign the right object to the left object. Both operands are of type MyTime. 3. Insertion << : Print the time in the format HH:MM SS PM. Left operand of type ostream and right operand of type MyTime. this in c++.
Create a class MyTime which has the datamembers as follows:
1. hour: integer (1 to 12)
2. minute: integer (0 to 59)
3. second: integer (0 to 59)
4. pm: bool variable. True means PM time and false means AM time.
Implement a default constructor, a parameterized constructor and a copy constructor. Write set and get functions for all the four members of the class.
Overload these operators:
1. Extraction operator >> : Prompt the user for hours, minutes, seconds and for am/pm and initialize the structure. Left operand istream object and right operand MyTime
2. Assignment = : Assign the right object to the left object. Both operands are of type MyTime.
3. Insertion << : Print the time in the format HH:MM SS PM. Left operand of type ostream and right operand of type MyTime.
this in c++.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images