Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // Project5.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10. class Point { //базовый класс
  11.  
  12. public:
  13. int x;
  14. int y;
  15.  
  16. void Show(string info)
  17. {
  18. cout « "Point" « info « ": (" « x « "," « y « ")" « endl;
  19. }
  20. };
  21.  
  22. class PointSpace : public Point //производный класс
  23. {
  24. public:
  25. int z;
  26. void Show(string info)
  27. {
  28. cout « "Point" « info « ": (" « x « "," « y « "," « z « ")" « endl;
  29. }
  30. };
  31. int main()
  32. {
  33. Point pointA;
  34. pointA.x = 0;
  35. pointA.y = 0;
  36. pointA.Show("A");
  37. PointSpace pointB;
  38. pointB.x = 1;
  39. pointB.y = 1;
  40. pointB.z = 1;
  41. pointB.Show("B");
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement