Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. class A {
  10. public:
  11.     virtual void foo() = 0;
  12. };
  13.  
  14. class B : public A {
  15. public:
  16.     void foo() {
  17.         cout << "I'm B." << endl;
  18.     }
  19. };
  20.  
  21. class C : public A {
  22. public:
  23.     virtual void foo() = 0;
  24. };
  25.  
  26. class D : public C {
  27. public:
  28.     void foo(){
  29.         cout << "I'm D." << endl;
  30.     }
  31. };
  32.  
  33. class E : public C {
  34. public:
  35.     void foo() {
  36.         cout << "I'm E." << endl;
  37.     }
  38. };
  39.  
  40. int main()
  41. {
  42.     A* b = new B();
  43.     A* d = new D();
  44.     A* e = new E();
  45.     b->foo();
  46.     d->foo();
  47.     e->foo();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement