대표적인 단항 연산자로는 다음 두 가지가 있다.
pos.operator++(); //멤버 함수로 오버로딩 되었을 경우
operator++(pos); //전역함수로 오버로딩 된 경우
Point&operator ++()
{
xpos+=1;
ypos+=1;
return *this;
}
public:
friend Point& operator--(Point &ref);
...
Point& operator--(Point &ref)
{
ref.xpos -=1;
ref.ypos -=1;
return ref;
}