Hey everyone, I need help with the following program. Define a class for a type
ID: 3616401 • Letter: H
Question
Hey everyone, I need help with the following program.Define a class for a type called CounterType. An object of this type is used toThanks!!
count things, so it records a count that is a nonnegative whole number. Include a
mutator function that sets the counter to a count given as an argument. Include
member functions to increase the count by one and to decrease the count by one.
Be sure that no member function allows the value of the counter to become negative.
Also, include a member function that returns the current count value and one that
outputs the count. In your test program, increment your counter to 10 and then
decrement down to 5 and display its values after each step
I have implemented class but I am not sure on how to approach the problem. I am posting my work below.
/*
Define 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 a
mutator function that sets the counter to a count given as an argument. Include
member functions to increase the count by one and to decrease the count by one.
Be sure that no member function allows the value of the counter to become negative.
Also, include a member function that returns the current count value and one that
outputs the count. In your test program, increment your counter to 10 and then
decrement down to 5 and display its values after each step
#include <iostream>
#include <cstdlib>
using namespace std;
class CounterType
{
public:
void setCount(int c);
void upCount();
void downCount();
int getCount();
private:
int count;
};
int main(){
CounterType counter;
system("pause");
return 0;
}
void CounterType::setCount(int c){
}
void CounterType::upCount(){
}
void CounterType::downCount(){
}