โ Back to Classes
Question 77
TimeDuration I/O (operator>> and operator<<)
TimeDuration I/O (operator>> and operator<<)
You are parsing and printing workout durations. Create a class TimeDuration that stores TWO ints: minutes and seconds. - seconds should always be 0..59 (normalize when reading). Input format for >> : two integers: minutes seconds (e.g., 3 15) Output format for << : M:SS (e.g., 3:15, 0:05) Requirements: 1) Default constructor sets minutes=0 and seconds=0 2) Overload operator>> to read minutes and seconds and normalize 3) Overload operator<< to print M:SS (SS must be 2 digits) Do NOT write a main function.
Expected Output:
3:15 0:05
Topics:
ClassesOperator Overloading
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.