mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Fix #998.
This commit is contained in:
parent
7146b55d30
commit
26f3ee9cfd
|
@ -20670,16 +20670,16 @@ Here is an example of the last option:
|
||||||
class B {
|
class B {
|
||||||
protected:
|
protected:
|
||||||
B() { /* ... */ }
|
B() { /* ... */ }
|
||||||
virtual void PostInitialize() // called right after construction
|
virtual void post_initialize() // called right after construction
|
||||||
{ /* ... */ f(); /* ... */ } // GOOD: virtual dispatch is safe
|
{ /* ... */ f(); /* ... */ } // GOOD: virtual dispatch is safe
|
||||||
public:
|
public:
|
||||||
virtual void f() = 0;
|
virtual void f() = 0;
|
||||||
|
|
||||||
template<class T>
|
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>();
|
auto p = make_shared<T>();
|
||||||
p->PostInitialize();
|
p->post_initialize();
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user