Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. // ConsoleApplication38.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
  2. //
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. class Shape
  7. {
  8. public:
  9. virtual void printShapeName() = 0;
  10. //{
  11. // cout << "Shape" << endl;
  12. //}
  13. };
  14. class Circle: public Shape
  15. {
  16. public:
  17. void printShapeName()
  18. {
  19. cout << "Circle" << endl;
  20. }
  21. };
  22. class Cylinder: public Shape
  23. {
  24. public:
  25. void printShapeName()
  26. {
  27. cout << "Cylinder" << endl;
  28. }
  29. };
  30. int main()
  31. {
  32. Cylinder a;
  33. Circle b;
  34. //Shape c;
  35. Shape* ptr;
  36. /*ptr = &c;*/
  37. ptr = &a;
  38. ptr->printShapeName();
  39. ptr = &b;
  40. ptr->printShapeName();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement