Skip to content

Instantly share code, notes, and snippets.

@Lipen
Last active August 3, 2016 07:50
Show Gist options
  • Save Lipen/61e1a0fe3a811596e9e38d57476ee1c0 to your computer and use it in GitHub Desktop.
Save Lipen/61e1a0fe3a811596e9e38d57476ee1c0 to your computer and use it in GitHub Desktop.
#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