新人请教this指针
class ww{
public:
ww(){a=10;}
~ww(){}
const ww& operator++()
private:
int a;
};
const ww& ww::operator++()
{ ++a;
return *this;
}
我是新手 我知道类中隐含this。
这里为什么要使用返回this指针呢?
请大哥大姐指导。
程序代码:#include <iostream>
using namespace std;
int main()
{
int a = 5;
++(++a); // a -> 7
++(a++); // Error!
return 0;
}
