//Point.h
#ifndef POINT_H
#define POINT_H
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
class Point {
public:
Point() :x(0), y(0) {}
Point(int x, int y) :x(x), y(y) {};
void setX(int x) {
this->x = x;
}
int getX() {
return this->x;
}
void setY(int y) {
this->y = y;
}
int getY() {
return this->y;
}
void print() {
cout << "(" << this->x << ", " << this->y << ")";
}
void moveRight(int offset) {
this->x = this->x + offset;
}
void moveDown(int offset) {
this->y = this->y + offset;
}
double distanceTo();
bool operator > (Point& point2);
~Point() {}
private:
int x;
int y;
};
double Point::distanceTo() {
return sqrt((this->x * this->x) + (this->y * this->y));
}
bool Point::operator > (Point& point2) {
if (this->distanceTo() > point2.distanceTo()) {
return true;
} else {
return false;
}
}
#endif
标签:return,Point,int,void,distanceTo,include,Class
From: https://www.cnblogs.com/catting123/p/16640781.html