#include <iostream>
using namespace std;
class Counter{
public:
Counter( void )
{
value=0;
cout<<"Constructor called !"<<endl;
}
void increment( void )
{
if( value<429467295 )
value++;
}
void decrement( void )
{
if( value>0 )
value--;
}
unsigned readValue( void )
{
return value;
}
~Counter( void )
{
cout<<"Destructor called !\n";
}
private:
unsigned value;
}
int main(int argc, char *argv[])
{
Counter c1,c2;
int i;
for( i=1;i<=6;i++ ){
c1.increment();
cout<<"Value of c1="<<c1.readValue()<<endl;
c2.increment();
}
cout<<"after loop Value of c2="<<c2.readValue()<<endl;
for( i=1;i<=5;i++ )
c2.decrement();
cout<<"Final value of c1="<<c1.readValue()<<",value of c2="<<c2.readValue()<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}