Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct Foo {
- Foo() : name(__func__) { }
- virtual string str() { return name; }
- string name;
- };
- struct Bar : Foo {
- Bar() : name(__func__) { }
- virtual string str() { return Foo::str() + "->" + name; }
- string name;
- };
- struct Baz : Bar {
- Baz() : name(__func__) { }
- virtual string str() { return Bar::str() + "->" + name; }
- string name;
- };
- int main() {
- Foo f;
- cout << f.str() << endl;
- Bar b;
- cout << b.str() << endl;
- Baz z;
- cout << z.str() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement