The benefits of the command pattern
If looking at all that crazy code makes your eyes glaze over, you are not alone. The complex syntax of function pointers and pointer to member functions calls are some of the most difficult parts of C++. For that reason, many people avoid them. However, they also miss out on the power offered by such features.
On the other hand, just because something is powerful, it doesn't mean it is always the right tool for the job. Simple is often better and, because of the many levels of indirection, code like we just saw has the chance to cause a lot of bugs. It will be up to you to decide if using these tools is right for your project. That being said, let's discuss some of the benefits of using the Command pattern so you can better decide when and where to use it.
Treating a function call like an object
The biggest benefit of using the Command pattern is that we are encapsulating the function or method call and the parameters. This means that everything needed for...