相关疑难解决方法(0)

为什么在类之外定义operator +或+ =,以及如何正确地执行它?

我对它们之间的差异感到有点困惑

Type  operator +  (const Type &type);
Type &operator += (const Type &type);
Run Code Online (Sandbox Code Playgroud)

friend Type  operator +  (const Type &type1, const Type &type2);
friend Type &operator += (const Type &type1, const Type &type2);
Run Code Online (Sandbox Code Playgroud)

哪种方式是首选,它们看起来像什么,什么时候应该使用?

c++ operator-overloading operators

27
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

operator-overloading ×1

operators ×1