Solution: Factory Method
Get a detailed explanation of the solutions to the factory methods exercises.
We'll cover the following...
We'll cover the following...
Solution to the first problem
Here is the refactored code using std::shared_ptr.
Code explanation
-
Lines 4–8: We created a
Windowbase class with one purevirtualmethodclone()with astd::shared_ptrreturn type. -
Lines 11–20: We created a
DefaultWindowclass derived from theWindowparent class. We created a constructor with no parameters, ...