CreateMaze is the function which instantiates the objects. IMO, according to factory pattern we are not supposed to overload or modify or re-write the function which instantiates objects.
But in the example, the CreateMaze function returns a Maze*. So, now if we have to write an EnchangedMaze class, will we have to re-write CreateMaze function to return a pointer of EnchantedMaze?
Changing the layout means changing this member function, either by overriding it—which means reimplementing the whole thing—or by changing parts of it—which is error-prone and doesn't promote reuse.
Isn't this what factory pattern wants to avoid?
What point am I missing?