Question
Using c++ Please make sure the code looks exactly the same as the sample when it is run. Implement a class for a type called
Using c++ Please make sure the code looks exactly the same as the sample when it is run.
Implement a class for a type called CounterType. An object of this type is used to count things, so it records a count that is a nonnegative whole number. Include the following functions in your class: - a member mutator function that sets the counter to a number given as an argument - a member function that increases the count by 1 - a member function that decreases the count by 1 if it does not result in count becoming negative - a member function that returns the current value of count - a member function that prints the current value of count to standard output Write a test program for your class in main(). Your program should prompt the user to enter a positive value to initialize the CounterType object, then subtract 1 from the object and print out the current value, add 1 to count and print out the current value, and print out the final value.
WORK AREA RESULTS a member function that returns the current value of count -a member function that prints the current value of count to standard outout Write a test program for your class in main). Your program should prompt the user to enter a positive value to initialize the CounterType obiect, then subtract 1 from the object and print out the current value, add 1 to count and print out the current value, and print out the final value. SAMPLE RUN # 1: ./CounterType Interactive SessonShow Invisibles Highlight: None # 1 Show Highlighted Only Enter a number to start with:10 The value after subtracting 1: 9 The value after adding 1: 10 Final valuei 10
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