-
-
Save anonymous/73572c610e3442bc126a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Base { | |
public: | |
Base() : next(NULL) {} | |
Base * next; | |
void frop() { | |
std::cout << "base frop" << std::endl; | |
} | |
}; | |
class Special : public Base { | |
public: | |
void frop() { | |
std::cout << "special frop" << std::endl; | |
} | |
}; | |
int main(char ** args) { | |
Base b1 = Base(); | |
Base b2 = Base(); | |
Special s1 = Special(); | |
b1.next = &s1; | |
s1.next = &b2; | |
Base * cur = &b1; | |
while(cur) { | |
cur->frop(); | |
cur = cur->next; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment