📄 tian1.cpp
字号:
#include<iostream.h>
class point
{public:
point& operator++();
point operator++(int);
point& operator--();
point operator--(int);
point(){_x=_y=0;}
int x(){return _x;}
int y(){return _y;}
private:
int _x,_y;
};
point& point::operator++()
{_x++;
_y++;
return *this;
}
point point::operator++(int)
{point temp=*this;
++*this;
return temp;
}
point& point::operator--()
{_x--;
_y--;
return *this;
}
point point::operator--(int)
{point temp=*this;
--*this;
return temp;
}
void main()
{point a;
cout<<a.x()<<","<<a.y()<<endl;
a++;
cout<<a.x()<<","<<a.y()<<endl;
++a;
cout<<a.x()<<","<<a.y()<<endl;
a--;
cout<<a.x()<<","<<a.y()<<endl;
--a;
cout<<a.x()<<","<<a.y()<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -