January 2019
Intermediate to advanced
512 pages
14h 5m
English
There are several reasons, but the simplest is that the memory must be allocated in the amount sizeof(T), where T is the actual object type, and the sizeof() operator is constexpr (a compile-time constant).
The Factory pattern is a creational pattern that solves the problem of creating objects without having to explicitly specify the type of the object.
While in C++ the actual type has to be specified at construction point, the Factory pattern allows us to separate the point of construction from the place where the program has to decide what object to construct and to ...