C++ this指针的问题

2025-04-09 12:10:52
推荐回答(1个)
回答1:

如果你想在类成员函数中显示调用类成员变量采用“this.成员变量”这种形式就行了,返回this指针:return this;
如:
ClassA setValue(int a) {
this.a = a;
return this;