Use of unary plus operator

前端 未结 4 1293
抹茶落季
抹茶落季 2021-01-04 19:09

I\'ve heard it is used as overloaded operator+ for example

class MyClass
{
    int x;
public:
    MyClass(int num):x(num){}
    MyClass operator+(const MyCla         


        
4条回答
  •  梦谈多话
    2021-01-04 19:31

    When an operator-function is a member function, it has one more argument (this) than explicitly mentioned in the declaration. So in your case it's the binary +, the first argument is this, the second is the passed argument.

提交回复
热议问题