返回操作符=重载对象

问题描述 投票:0回答:1

归来的区别是什么?*this 还是 C++ 中 operator= 的实现中给定的参数?如果是,为什么?

   class Object {
   public:
      Object operator=(Object Obj) {
         return *this;
      }
   }

   class Object {
   public:
      Object operator=(Object Obj) {
         return Obj;
      }
   }
c++ operator-overloading this operator-keyword
1个回答
1
投票

X& operator=( X const& ) { return *this; } 的语义相匹配。= 关于 int. 你给出的其他建议没有。 当有疑问时,请匹配以下的语义 int.

© www.soinside.com 2019 - 2024. All rights reserved.