• Increase font size
  • Default font size
  • Decrease font size
To err is human, but to really foul things up requires a computer.

C++ member function pointers and delegates

Delegates is a concept widely used in design patterns like Observer or Strategy.

Standard C++ doesn't provide delegates, but this can be implemented using member function pointers. The problem is that C++'s object-oriented function pointers have a complicated syntax and have wierd behavior when dealing with inherited classes.

There has been a lot of discussion on this topic and many implementations exists.