Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- class A {
- public:
- virtual void foo() = 0;
- };
- class B : public A {
- public:
- void foo() {
- cout << "I'm B." << endl;
- }
- };
- class C : public A {
- public:
- virtual void foo() = 0;
- };
- class D : public C {
- public:
- void foo(){
- cout << "I'm D." << endl;
- }
- };
- class E : public C {
- public:
- void foo() {
- cout << "I'm E." << endl;
- }
- };
- int main()
- {
- A* b = new B();
- A* d = new D();
- A* e = new E();
- b->foo();
- d->foo();
- e->foo();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement