<分区>
我的问题是指当我想调用同一个类的其他方法时的情况。使用和不使用“this”有什么区别?与类的变量相同。通过“this”访问这些变量有区别吗?是否与那些方法/变量是私有(private)的还是公共(public)的有关?示例:
class A {
private:
int i;
void print_i () { cout << i << endl; }
public:
void do_something () {
this->print_i(); //call with 'this', or ...
print_i(); //... call without 'this'
this->i = 5; //same with setting the member;
i = 5;
}
};