Last active
March 10, 2019 08:46
-
-
Save fullmated/e5cf793be9c025510eae309913689fb1 to your computer and use it in GitHub Desktop.
Effective C++ #9 before
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> | |
#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