Factory Design Pattern C++