原文: A& operator=(const A& a){ num1 = a.num1 + 1; num2 = a.num2 + 1; return *this; }; 是不是应该这样: A& operator=(const A& a) { this->num1 = a.num1 + 1; this->num2 = a.num2 + 1; return *this; };
Activity
1031507008 commentedon Dec 20, 2023
QinglinQAQ commentedon Dec 20, 2023
原文:
A& operator=(const A& a){
num1 = a.num1 + 1;
num2 = a.num2 + 1;
return *this;
};
是不是应该这样:
A& operator=(const A& a) {
this->num1 = a.num1 + 1;
this->num2 = a.num2 + 1;
return *this;
};