Skip to content

Instantly share code, notes, and snippets.

Created September 8, 2013 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/73572c610e3442bc126a to your computer and use it in GitHub Desktop.
Save anonymous/73572c610e3442bc126a to your computer and use it in GitHub Desktop.
#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