//
// Created by 刘彪 on 2020/3/1.
//p159运行结果与书本不一样(最后2行) 应该书本错了
#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
class Point{
int x,y;
public:
Point(){
x = y =0;
}
Point(int i,int j){
x= i;
y = j;
}
Point(Point &);
~Point(){}
void offset(int,int);
void offset(Point);
bool operator == (Point);
bool operator != (Point);
void operator += (Point);
void operator -= (Point);
Point operator + (Point);
Point operator -(Point);
int getx(){return x;}
int gety(){return y;}
void disp(){cout << "("<<x<<","<<y<<")"<<endl;}
};
Point::Point(Point &p) {
x = p.x;y = p.y;
}
void Point::offset(int i, int j) {
x+=i;y+=j;
}
void Point::offset(Point p) {
x+=p.getx();
y+=p.gety();
}
bool Point::operator==(Point p) {
if(x==p.getx() && y==p.gety()) return 1;else return 0;
}
bool Point::operator!=(Point p) {
//ziji
return (x!=p.gety() || y!=p.gety()) ? 1:0;
}
void Point::operator+=(Point p) {
x+=p.getx();
y+=p.gety();
}
void Point::operator-=(Point p) {
x-=p.getx();
y-=p.gety();
}
Point Point::operator+(Point p) {
this->x+=p.x;
this->y+=p.y;
return *this;
}
Point Point::operator-(Point p) {
this->x-=p.x;
this->y-=p.y;
return *this;
}
int main(){
Point p1(2,3),p2(3,4),p3(p2);
cout<<"1:";
p3.disp();
p3.offset(10,10);
cout<<"2:";
p3.disp();
cout<<"3:"<<(p2==p3)<<endl;
cout<<"4:"<<(p2!=p3)<<endl;
p3+=p1;
cout<<"5:";
p3.disp();
p3-=p2;
cout<<"6:";
p3.disp();
p3=p1+p2;
cout<<"7:";
p3.disp();
p3=p1-p2;
cout<<"8:";
p3.disp();
return 0;
}