fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. class Point {
  5. private:
  6. int _x;
  7. int _y;
  8.  
  9. public:
  10. Point(int x, int y) {
  11. this->_x = x;
  12. this->_y = y;
  13. }
  14.  
  15. double getDistance(Point* p) {
  16. return sqrt(pow(this->_x - p->_x, 2) + pow(this->_y - p->_y, 2));
  17. }
  18. };
  19.  
  20. int main() {
  21. Point* a = new Point(0, 0);
  22. Point* b = new Point(10, 10);
  23.  
  24. std::cout << a->getDistance(b) << std::endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 4572KB
stdin
Standard input is empty
stdout
14.1421