class sample
{
private:
int radius;
float x,y;
public:
circle()
{
}
circle(int rr;float xx;float yy)
{
radius=rr;
x=xx;
y=yy;
}
circle operator =(circle& c)
{
cout << endl<<"Assignment operator invoked";
radius=c.radius;
x=c.x;
y=c.y;
return circle(radius,x,y);
}
}
int main()
{
circle c1(10,2.5,2.5);
circle c1,c4;
c4=c2=c1;
}
In the overloaded '=' function the statements
radius=c.radius;
x=c.x;
y=c.y;
itself make all of c2's data members equal to c1's , so why is a return necessary? Similarly, in c1=c2+c3, c2 and c3 are added using an overloaded + operator and the value is returned to c1, but doesn't that become c1=, so shouldn't we be using another = operator to assign the sum of c2 and c3 to c1? I'm confused.