代入演算子のオーバーロードに次のコードを使用しました。
SimpleCircle SimpleCircle::operator=(const SimpleCircle & rhs)
{
if(this == &rhs)
return *this;
itsRadius = rhs.getRadius();
return *this;
}
私のコピーコンストラクタはこれです:
SimpleCircle::SimpleCircle(const SimpleCircle & rhs)
{
itsRadius = rhs.getRadius();
}
上記の演算子オーバーロードコードでは、新しいオブジェクトが作成されているときにコピーコンストラクターが呼び出されます。したがって、私は以下のコードを使用しました:
SimpleCircle & SimpleCircle::operator=(const SimpleCircle & rhs)
{
if(this == &rhs)
return *this;
itsRadius = rhs.getRadius();
return *this;
}
完全に機能し、コピーコンストラクターの問題は回避されますが、これに関して(私にとって)未知の問題はありますか?