<h2>The definition of a class Counter </h2>
class Counter
{
Private : //access modifier
int counter; //defining and initialising variables
int counterID;
static int nCounters=0;
Public : //access modifier
Counter(int a) //defining functions
{
counter=a; //initialising variable counter with argument a
nCounters++; //incrementing 1 to variable nCounters
}
void increment()
{
counter=counter + 1;
}
void decrement()
{
counter=counter - 1;
}
int getValue()
{
return counter; //returning integer value contained in counter
}
int getCounterID()
{
return counterID; //returning integer value contained in counter
}
}; //class definition ends