C++Point类运算符重载
#include "stdafx.h"
using namespace std;
class Point
{
public:
Point(double x,double y):_x(x),_y(y)
{
}
~Point()
{
}
什么是间接转述句Point& operator ++();
Point operator ++(int);
Point& operator --();
Point operator --(int);临汾牛肉丸子面
friend ostream& operator <<(ostream& out,Point& a);
private:
double _x,_y;
};
Point& Point::operator++()硅石矿
{
马若特
_x++;
_y++;
return *this;
}
Point Point::operator++(int)
直为斩楼兰{
Point old=*this;
++(*this);
return old;
}
Point& Point:: operator --()
读书卡片图片大全
{
_x--;
_y--;
return *this;
}
Point Point::operator --(int)
{
Point old=*this;
--(*this);
return old;
极其的近义词}
ostream& operator<<(ostream& out,Point &a)
{
out<<"("<<a._x<<","<<a._y<<")";
return out;
}
化学会int main()
{
Point a(1,1);
a++;
cout<<a<<endl;
system("Pau");
return 0;
}