Go away. This blog is dead.
I good righter.
Now shoo.
August 10, 2008
August 3, 2008
Overloading "=" operator
//Write a program to overload the = operator, and assign data members of one object to that of another object of the same type.
using namespace std;
class sum
{ public:
int sum1;//,imanidiotwhoneedlesslycomplicatesthings;
int a,b,c;
sum()
{a=0;
b=0;
c=0;
}
void operator=(sum &d2);
}d1,d2;
void sum::operator=(sum &d2)
{ d2.a=d1.a;
d2.b=d1.b;
d2.c=d1.c;
cout<<"\nAssign invoked\n";
}
main()
{int a,b,c,d;
cout<<\nEnter int a,b,c to be copied:";
cin>>d1.a>>d1.b>>d1.c;
printf("Elements of obj1:\n%d\n%d\n%d",d1.a,d1.b,d1.c);
d1=d2;