Point.h class Point{ private: int X ; int Y ; public: Point(); Point(int x ,int y) ; Point & operator =(Point &A) ; Point operator +(Point A) ; int get_X() ; int get_Y() ; ~Point(void); };
Point.cpp #include "Point.h" Point::Point(void){} Point::~Point(void){} Point::Point(int x ,int y):X(x),Y(y){} Point& Point::operator=(Point & A){ X=A.X ; Y=A.Y ; return *this ; } Point Point::operator +(Point A){ return Point(X+A.X,Y+A.Y) ; } int Point::get_X(){ return X ; } int Point::get_Y(){ return Y ; }
void CMFCPointDlg::OnClickedButtonAddPoint() { // TODO: 在此添加控件通知处理程序代码 UpdateData(true) ; Point A(A_x,A_y) ; Point B(B_x,B_y) ; Point ans=A+B ; C_x=ans.get_X() ; C_y=ans.get_Y() ; UpdateData(false) ; }