Thursday, September 22, 2016

Overloading Assignment Operator

Tags

Program To Overload Assignment Operator:

#include<iostream>
using namespace std;
class na
{
int x,y;
public:
na()
{x=0;
y=0;
}
na(int a,int b)
{
x=a;y=b;
}
void operator =(na &s)
{
x=s.x;
y=s.y;
}
void display()
{
cout<<"\n"<<x<<"\n"<<y;
}

};
main()
{
na c(150,142),d;
d=c;
c.display();
cout<<"Values of Another Object";
d.display();
}