Last active
August 3, 2016 07:50
-
-
Save Lipen/61e1a0fe3a811596e9e38d57476ee1c0 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> | |
using std::cout; | |
using std::endl; | |
struct Foo { | |
void say() const { | |
cout << "Foo says: " << msg << endl; | |
} | |
protected: | |
Foo(const char* msg = ""): msg(msg) { | |
cout << "Foo ctor" << endl; | |
} | |
private: | |
const char* msg; | |
}; | |
struct Bar: Foo { | |
Bar(const char* msg): Foo(msg) { | |
cout << "Bar ctor" << endl; | |
} | |
}; | |
int main() { | |
Bar b("jelly"); | |
b.say(); | |
cout << "End." << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment