Using the abstract factory method
An abstract factory is a part of the creational design pattern. It is one of the best ways to create an object and is a commonly repeated design pattern in games. It is like a factory of factories. It uses an interface to create a factory. The factory is responsible for creating objects without specifying their class type. The factory generates these objects based on the factory method design pattern. However, some argue that the abstract factory method can also be implemented using the prototype design pattern.
Getting ready
You need to have a working copy of Visual Studio installed on your Windows machine.
How to do it…
In this recipe, we will find out how easy it is to implement the abstract factory pattern:
Open Visual Studio.
Create a new C++ project.
Select a Win32 console application.
Add a source file called
Source.cpp
.Add the following lines of code to it:
#include <iostream> #include <conio.h> #include <string> using namespace std; ...