C++ Question

In c++, Define a class counterType to implement a counter. Your class must have a private data member counterof type int. Define a constructor that accepts a parameter of type int and initializes the counterdata member. Add functions to:

  • Set counter to the integer value specified by the user.
  • Initialize counter to 0.
  • Return the value of counter with a function named getCounter.
  • Increment and decrement counter by one.
  • Print the value of counter using the printfunction.
    • Example output: Counter = 0.

The value of counter must be nonnegative.

Task 1: Included the private member variable counter

Task 2: counterType‘s getCounterreturns the value of counter

Task 3: counterType‘s incrementCounter increments the value of counter

Task 4: counterType‘s decrementCounter decrements the value of counter

Task 5: counterType‘s print prints the value of counter

Requirements:

Click here to order similar paper @Udessaywriters.com.100% Original.Written from scratch by professional writers.

You May Also Like

About the Author: admin