← Back to Classes
Question 86
Book Progress (operator-= and operator>=)
Book Progress (operator-= and operator>=)
You are tracking reading progress using current page and total pages.
Create a class ReadingProgress that stores TWO ints: currentPage and totalPages.
Pages left = totalPages - currentPage.
Requirements:
1) Constructor ReadingProgress(int currentPage, int totalPages)
2) int getPagesLeft() const
3) operator-=(int pagesRead) increases currentPage by pagesRead (do not exceed totalPages) and returns *this
4) operator>=(int pages) returns true if pagesLeft >= pages
Do NOT write a main function.Expected Output:
60 true 10 false 0 false
= newline. The output ends with a newline — print one after the last line.
Hints4 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.