point.cpp 448 B

123456789101112131415161718192021222324252627282930313233
  1. #include <cmath>;
  2. #include <iostream>;
  3. #include "point.h"
  4. using namespace std;
  5. Point::Point()
  6. {
  7. }
  8. //Point
  9. const double
  10. Point::calc_distance(const Point& p) {
  11. double dx = x - p.x;
  12. double dy = y - p.y;
  13. return sqrt(dx * dx + dy * dy);
  14. }
  15. istream& operator>>(istream& is, Point a)
  16. {
  17. return is >> a.x >> a.y;
  18. }
  19. ostream& operator<<(ostream& os, Point a)
  20. {
  21. return os << "(" << a.x << ", " << a.y << ")";
  22. }