#include<iostream.h>
#include<conio.h>
class counter
{
int count;
public:
counter()
{
count=0;
}
int get_count()
{
return count;
}
void operator++()
{
count++;
}
};
void main()
{
counter c1,c2;
cout<<"\nC1 ="<<c1.get_count();
cout<<"\nC2 ="<<c2.get_count();
c1++; //Using overloaded ++ operator.
c2++;
++c2;
cout<<"\nC1 ="<<c1.get_count();
cout<<"\nC2 ="<<c2.get_count();
getch();
}
OUT PUT:
C1=0 C2=O
C1=1 C2=2
Not Satisfied ? Just search & get the result
Related posts:
- C++ program – Perform arithmetic operations of two complex numbers using operator overloading
- C++ program – Perform complex arithmetic using operator overloading
- C++ program – multiply two numbers without using multiplication operator
- C++ program to implement Heap sort Algorithm
- C++ program to implement Selection sort using class
