From b16ef0236580644815553b1820bc4b55c45693d9 Mon Sep 17 00:00:00 2001 From: hsutter Date: Wed, 2 Dec 2015 12:42:04 -0800 Subject: [PATCH] Extended Sd-factory example per issue #310 --- CppCoreGuidelines.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 915dfbc..8e4a0a2 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -13484,9 +13484,19 @@ Here is an example of the last option: return p; } }; + + + class D : public B { // some derived class + public: + void f() override { /* ... */ }; - class D : public B { /* "¦ */ }; // some derived class + protected: + D() {} + template + friend shared_ptr B::Create(); + }; + shared_ptr p = D::Create(); // creating a D object This design requires the following discipline: