Hi, I need help with my '=' assignment operator as shown below. Basically I need to also assign an int value along with the point. Refer below. May I know how I can achieve that? Your help will be much appreciated.
Circle& Circle::operator= (const Circle& a) // need to have int value
{
p1 = a.p1;
x = a.x;
return *this;
}
Or if you meant to, you could introduce another overload to assignment which takes an int as argument.
1 2 3 4 5 6
Circle& Circle::operator= (constint& a) // need to have int value
{
x = a;
return *this;
}
If that's what you want to achieve then you probably also want an overload accepting Point.
1 2 3 4 5 6
Circle& Circle::operator= (const Point& a) // need to have int value
{
p1 = a;
return *this;
}
But it wouldn't make sense to use the assignment operator for modifying particular data members.
You could instead use methods. void Circle::set_int (int value) { x = value; }