This commit is contained in:
Gabriel Dos Reis 2017-09-11 10:48:20 -07:00
parent 7146b55d30
commit 26f3ee9cfd

View File

@ -20670,16 +20670,16 @@ Here is an example of the last option:
class B {
protected:
B() { /* ... */ }
virtual void PostInitialize() // called right after construction
virtual void post_initialize() // called right after construction
{ /* ... */ f(); /* ... */ } // GOOD: virtual dispatch is safe
public:
virtual void f() = 0;
template<class T>
static shared_ptr<T> Create() // interface for creating objects
static shared_ptr<T> create() // interface for creating objects
{
auto p = make_shared<T>();
p->PostInitialize();
p->post_initialize();
return p;
}
};