assignment operator overloading in c++

前端 未结 6 1942
醉梦人生
醉梦人生 2021-02-01 15:07

I have used the following code for assignment operator overloading:

SimpleCircle SimpleCircle::operator=(const SimpleCircle & rhs)
{
     if(this == &rhs         


        
6条回答
  •  故里飘歌
    2021-02-01 15:23

    There are no problems with the second version of the assignment operator. In fact, that is the standard way for an assignment operator.

    Edit: Note that I am referring to the return type of the assignment operator, not to the implementation itself. As has been pointed out in comments, the implementation itself is another issue. See here.

提交回复
热议问题