PDA

Click to See Complete Forum and Search --> : = operator overload


DNA7433
Apr 25th, 2002, 08:00 PM
whats the syntax for overloading the = operator?

CornedBee
Apr 26th, 2002, 09:45 AM
class Something
{
Something& operator = (const argtype &arg);
};

is the usual way. The last statement should be
return *this;
This way you can do
Something o1, o2, o3;
o1 = o2 = o3 = 234;

You can define as many different = operators as you want, as long as they can be distinguished by the compiler.

DNA7433
Apr 26th, 2002, 02:41 PM
thanks