I have used the following code for assignment operator overloading:
SimpleCircle SimpleCircle::operator=(const SimpleCircle & rhs) { if(this == &rhs) return *this; itsRadius = rhs.getRadius(); return *this; } My Copy Constructor is this:
SimpleCircle::SimpleCircle(const SimpleCircle & rhs) { itsRadius = rhs.getRadius(); } In the above operator overloading code, copy constructor is called as there is a new object is being created; hence I used the below code:
SimpleCircle & SimpleCircle::operator=(const SimpleCircle & rhs) { if(this == &rhs) return *this; itsRadius = rhs.getRadius(); return *this; } Its working perfectly and the copy constructor problem is avoided, but is there any unknown issues (to me) regarding this ?