← Back to Classes
Question 72
Scale a Duration (operator*)
Scale a Duration (operator*)
You are scaling workout durations.
Create a class Duration that stores seconds as an int.
Requirements:
1) Constructor Duration(int seconds)
2) int getSeconds() const
3) Overload operator* to allow: Duration newDur = dur * factor;
(factor is an int)
Do NOT write a main function.Expected Output:
180 0
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
ClassesOperator Overloading
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.