Understanding the flow of execution and debugging
Much of the last four chapters has been about the code structure. It is very possible that you still have doubts and uncertainties about which class instantiates which instance or in what order the various functions are called. Wouldn't it be useful if there was a way to execute the project and follow the path of execution from int main()
right through to return 0;
in the Space Invaders ++.cpp
file? It turns out we can, and the following is how to do it.
We will now explore the debugging facilities in Visual Studio while simultaneously trying to understand the structure of the project.
Open the Space Invaders ++.cpp
file and find the first line of code, as follows:
GameEngine m_GameEngine;
The preceding code is the first line of code that gets executed. It declares an instance of the GameEngine
class and sets all our hard work in motion.
Right-click the preceding line of code and select Breakpoint | Insert Breakpoint...