Question: Define a class for a type called Counter. An object of this type is used to count things. Include a default constructor that sets the
Define a class for a type called Counter. An object of this type is used to count things. Include a default constructor that sets the counter to zero and a constructor with one argument that sets the counter to the value specified by its argument. Write member functions to increase the value by one called increment and decrease the value by one called decrement don't let the value go below zero. Write a member function print that prints out the value of the counter.
Here's a driver program that you should include to test your class.
tablemainCounter c;Counter c;cout C starts at ;cprint;cout endl;cincrement;cincrement;cout C now at ;cprint;cout endl;;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
