fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. class Ponto {
  6. public:
  7. Ponto(int x1, int y1) : x(x1), y(y1) {}
  8.  
  9. double calcular_distancia(Ponto &outro) {
  10. int a = x - outro.x;
  11. int b = y - outro.y;
  12. return sqrt(a * a + b * b);
  13. }
  14.  
  15. int inline get_x() {
  16. return x;
  17. }
  18.  
  19. int inline get_y() {
  20. return y;
  21. }
  22. private:
  23. int x;
  24. int y;
  25. };
  26.  
  27. int main() {
  28. Ponto p1(2, -3);
  29. Ponto p2(4, 5);
  30. double distancia = p1.calcular_distancia(p2);
  31. cout << distancia;
  32. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
8.24621