Skip to content

Instantly share code, notes, and snippets.

@fullmated
Last active March 10, 2019 08:46
Show Gist options
  • Save fullmated/e5cf793be9c025510eae309913689fb1 to your computer and use it in GitHub Desktop.
Save fullmated/e5cf793be9c025510eae309913689fb1 to your computer and use it in GitHub Desktop.
Effective C++ #9 before
#include <iostream>
#include <memory>
class Base {
public:
Base() { init(); }
virtual void log() const = 0;
private:
void init() {
std::cout << "do something" << std::endl;
log();
}
};
class Derived : public Base {
public:
Derived() {};
virtual void log() const {}
};
int main(void){
std::unique_ptr<Derived> ptr = std::make_unique<Derived>();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment