I am trying to use overloading concept to equate 3 objects c1
, c2
, c3
.
But it is giving me an error
error: no match for 'operator=' in 'c3 = c2. circle::operator=(((circle&)(& c1)))'
What's the reason behind it how do I rectify it??
#include<iostream>
using namespace std;
class circle
{
private:
int radius;
float x,y;
public:
circle()
{}
circle(int rr,float xx,float yy)
{
radius=rr;
x=xx;
y=yy;
}
circle& operator=(const circle& c)
{
cout<<endl<<"assignment operator invoked";
radius=c.radius;
x=c.x;
y=c.y;
return *this;
}
void showdata()
{
cout<<endl<<"\n radius="<<radius;
cout<<endl<<"x coordinate="<<x;
cout<<endl<<"y coordinate="<<y<<endl;
}
};
int main()
{
circle c1 (10,2.5,2.5);
circle c2,c3;
c3=c2=c1;
c1.showdata();
c2.showdata();
c3.showdata();
return 0;
}
so this overloaded operator will be called two times.. First for c2=c1 and then for c3=c2 but how will compiler compare it with overloaded operator definition??