#include<iostream.h>
#include<conio.h>
class increment
{
private:
                int a,b;
public:
                increment(int p,int q)
                                {
                                a=p;
                                b=q;
                                }
                void operator ++ ()
                                {
                                ++a;
                                ++b;
                                }
                void display()
                                {
                                cout<<"A = "<<a<<"\tB = "<<b<<endl;
                                }
};
void main()
{
                clrscr();
                increment x(5,3);
                ++x;
                cout<<"After Operator Overloading \n";
                x.display();
                getch();
}

179.PNG

Advertisements