fork download
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. struct Point //структура (почти класс)
  7. {
  8. double x; //поле
  9. double y;
  10.  
  11. Point()
  12. {
  13. }
  14.  
  15. Point(double xx, double yy = 5) //конструктор
  16. : x(xx), y(yy)
  17. {
  18. if (x < 0)
  19. x = 0;
  20. if (y < 0)
  21. y = 0;
  22. }
  23.  
  24. double dist() //метод
  25. {
  26. return sqrt(x * x + y * y);
  27. }
  28.  
  29. double scl(Point other)
  30. {
  31. return x * other.x + y * other.y;
  32. }
  33. };
  34.  
  35. int main()
  36. {
  37. Point p(4.2, 5.3); // экземпляр структуры (объект)
  38.  
  39. Point p(3.9);
  40.  
  41. Point p2;
  42. p2.x = 3.5;
  43. p2.y = p.x;
  44.  
  45. cout << p.dist() << endl;
  46. cout << p.scl(p2) << endl;
  47. }
  48.  
  49.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:10: fatal error: pch.h: No such file or directory
 #include "pch.h"
          ^~~~~~~
compilation terminated.
stdout
Standard output is empty