# include < iostream.h >
class counter
   {
private: unsigned int count; 
public : counter() {count = 0;}
int get_count () { return count;}
void operator ++() {count++;}
    };
void  main()
{
counter c1 ,c2;
cout << "\n c1 =" << c1.get_count(); 
cout << "c2 ="<< c2.get_count(); 
c1++; 
c2++; 
++c2; 	
cout << "\n c1 ="<< c1 .get_count(); 
cout << "c2=" << c2.getcount();
}
Output of the Example
c1=0			c2=0
c1=1			c2=2
Click here to go back.  

Our aim is to provide information to the knowledge seekers. 


comments powered by Disqus


Footer1