I understand "this" is for obtaining the object's address. And I understand that "this" is useful for assignment, for eg:
But why do I see people writing code like this:Code:class A{ A operator =(const A& rhs){ if(this != &rhs){...} } };
Can't we just writeCode:class A{ //..omit constructor... void foo1(){ this->foo2(val_); } void foo2(int val){ val++; } private: int val_; }
Code:void foo1(){ foo2(val_); }