#include<iostream.h>
#include<conio.h>
class Increment
{
private:
int count;
public:
//*****Member Function Definitions******
Increment( ) // Default Constructor
{
count = 0 ;
}
Increment(int C) // Constructor with Argument
{
count = C ;
}
Increment operator ++ ( ) // Operator Function Definition
{
count++;
return Increment(count);
}
void display(void) // Function for displaying the output
{
cout << count << endl ;
}
}; // End of the class definition
void main(void)
{
Increment l1,l2(5),l3,l4 ;
clrscr();
cout <<"\n Before Activating the Operator ++( )\n" ;
cout << "l1=";
l1.display( );
cout << "l2= ";
l2.display( );
++l1 ; // l1and l2are incremented
l2++ ;
cout << "\n After Activating the Operator ++(.)\n" ;
cout << "l1= ";
l1.display( );
cout << "l2= " ;
l2.display( ) ;
l3= ++l1 ; /* Here, the objects 11and 12are incremented again and their 14=12++; values are assigned to the objects 13and 14respectively */
cout << "l3= ";
l3.display( ) ;
cout << "l4= ";
l4.display( ) ;
getch();
}