In c++, Define a class counterType to implement a counter. Your class must have

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 main.cpp was provided: #include
#include “counterType.h”
#include
using namespace std;
int main()
{
counterType counter1;
counterType counter2(5);
counter1.print();
cout << endl; counter1.incrementCounter(); cout << "After Increment counter1: " << counter1.getCounter() << endl; cout << "Counter2 = " << counter2.getCounter() << endl; counter2.decrementCounter(); cout << "After decrement counter2 = " << counter2.getCounter() << endl; counter1.setCounter(-6); cout << "After resetting counter1: " << counter1.getCounter() << endl; return 0; }

Posted in C++

Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount