HOME

Sunday, November 29, 2015

BINARY * OVERLOADING USING MEMBER FUNCTION

#include<iostream>
using namespace std;
class sample
{
    int a;
public:
    void getdata()
    {
        cout<<"ENTER NUMBER"<<endl;
        cin>>a;
    }
    void display()
    {
        cout<<"VALUE = "<<a<<endl;
    }
    sample operator *(sample &obj)
    {
       sample temp;
       temp.a=a*obj.a;
       return temp;
    }
};
int main()
{
sample s1,s2,s3;
s1.getdata();
s2.getdata();
s1.display();
s2.display();
s3=s1*s2;
s3.display();
return 0;
}

No comments:

Post a Comment