April 2017
Beginner to intermediate
394 pages
9h 16m
English
We saw that one limitation of using function pointers was that the signatures must be the same. They must have the same return type, as well as the same parameter types and count. We can already see that this isn't true with the Command pattern. The client doesn't need to know or care about the specific signature at call time since every command shares the common Execute interface. As an example, let's look at a function with more than one parameter and create a command for that type. Here is the function:
int Add(int x, int y) { return x + y; }
As we mentioned before, the complexity of the function isn't important. For now, let's focus on functions that take more than one parameter, as in the case of this Add ...
Read now
Unlock full access