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

180.PNG

Advertisements