point point::operator++(int){
point a=*this;
x++;
y++;
return a;
}
point point::operator--(int){
point a=*this;
x--;
y--;
return a;
}
//改变的不是声明的另一变量吗,而且前置有&,是引用传递,而后置是值传递,不理解这个对象怎么变的
T x=y++;//x等于++之前的y,然后y自身++
T x=++y; //x等于++之后的y,
这是++运算符的基础知识
那么 operator++(int) 对应的 y++就应该可以理解了
point point::operator++(int){
point a=*this;
x++;//因为这是类成员函数相当于this->x++;所以函数结束后 自身的x,y,自动增1了
y++;//
return a;//a等于之前的this,
}
而后缀++ ,返回的是引用,就是那个函数里面的this ,this ++ 了自然外部的变量也++了
函数体里有,x++;x--;就是对本体修改