#include <iostream>
using namespace std;
class point{
private:
int a,b;
public:
point(int a, int b){ //构造方法
this->a = a;
this->b = b;
}
int getA(){
return this->a;
}
int getB(){
return this->b;
}
void add(int a, int b){ //点相加
this->a += a;
this->b += b;
printf("a+b=(%d, %d)\n",this->a, this->b);
}
void add(point p){
add(p.getA(), p.getB());
}
void operator += (point p){ //运算符重载
this->add(p.getA(), p.getB());
}
};
int main(){
point * p = new point(5, 5);
//p->add(2,2);
(*p) += point(2, 2);//此处可以直接使用 += 来进行类的运算
system("pause");
return 0;
}