April 2017
Beginner to intermediate
394 pages
9h 16m
English
So far, we have seen how we can use the Command pattern with function pointers and allow the client to call our functions without caring about the parameter types or counts. This is incredibly useful. But what about using commands with C++ objects? While we can get commands to work with objects, we need to think about the problem a little first.
The most basic way to call member functions is to simply hardcode them in the Execute method. For example, we could pass in an object to a command constructor and always call a very specific function. In the example, m_gameObject is a pointer to an object that was passed to the constructor. However, Draw is the hardcoded method that we always call. This is the same as ...
Read now
Unlock full access