HOME

Sunday, November 29, 2015

DECREMENT OPERATOR OVERLOADING

#include<iostream>
using namespace std;
class decrement
{
    int a,b;
public:
    void getdata(int x, int y)
    {
    a=x;
    b=y;
    }
    void display()
{
    cout<<"DECREMENT VALUE OF A = "<<a<<endl;
    cout<<"DECREMENT VALUE OF B = "<<b<<endl;
}
    friend void operator--(decrement &obj);
};
void operator--(decrement &obj)
{
    --obj.a;
    --obj.b;
}

int main()
{
    decrement s;
    s.getdata(6,7);
    --s;
    s.display();
}

No comments:

Post a Comment