Question
Write a class called Book that has two private member variables called page (integer) and topic (string). It also has a static private member variable
Write a class called Book that has two private member variables called page (integer) and topic (string). It also has a static private member variable called count (integer). This class has only one constructor with default argument for page and topic. Write this constructor. Also overload the addition operator for this class such that it will add an integer value to the page variable of the book. For example when in main we say:
book2 = book1 + 4; then 4 will be added to the value of page. Also show how main can use the count variable to find out how many book objects are there.
The things that you should write:
1- class header defining member variables, addition operator overloading, setters, getters and constructor with default argument.
2- Implementation of constructor with default argument and the addition operator overloading as shown above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started