Advertisement
bar2104

OOP

Nov 12th, 2020
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class A
  6. {
  7. public:
  8.     A(){};
  9.     void virtual move()=0;
  10. };
  11.  
  12. class B1: public A
  13. {
  14. public:
  15.     B1(){};
  16.     void virtual move(){
  17.         cout<<2<<endl;
  18.     }
  19. };
  20. class B3: public A
  21. {
  22. public:
  23.     B3(){};
  24.     void virtual move(){
  25.         cout<<3<<endl;
  26.     }
  27. };
  28.  
  29.  
  30. int main()
  31. {
  32.     A* t;
  33.     t = new A;
  34.     t->move();
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement