用C++ 定义Point类,有坐标x,y两个成员变量,对Point类重载 “++” (自增),”--”(自减)运算符

2024-11-30 00:34:35
推荐回答(2个)
回答1:

现存的CPoint ;类就可以

回答2:

class Point
{
int x,y;
friend Point operator ++(point&);
friend Point operator --(point&);
};
Point operator++(Point &op)
{
++op.x;
++op.y;
}
Point operator--(Point &op
{
--op.x;
--op.y;
}