Why this post?
Because this looks like magic!
Code
// pointer to a member function
#include <iostream>
using namespace std;
class Dog
{
public:
void wag_tail() const
{
cout << "Tail left. Tail right. Wagging tail!" << endl;
}
void bark() const
{
cout << "Barrrrrrrrrrrk!" << endl;
}
};
int main()
{
Dog dog;
Dog * pdog = & dog;
void (Dog::*pfunc)() const = 0;
// point pfunc to wag_tail
pfunc = Dog::wag_tail;
(dog.*pfunc)(); // do NOT leave the first ()
(pdog->*pfunc)(); // do NOT leave the first ()
return 0;
}