Help me understand the following code snippet:
(foo.h)
class Foo
{
public:
typedef void (MyType::*Handler)(SomeOtherType* t);
Foo(Handler handler) : handler_(handler) { }
private:
Handler handler_;
};
(mytype.h)
class MyType
{
public:
MyType() { }
void fun1() { }
void fun2() { }
};
What exactly is the typedef in foo.h declaring here? I can see that it's a function pointer of some kind but what's the significance of the asterisk? It appears to be de-referencing a type (??) and somehow trying to "attach" the newly typedef'd pointer to the type of MyType (?!?).
Can someone shed some light here please? Really confused :S
void (MyType::*)(SomeOtherType* t)
is a pointer to a member function in class MyType
that takes one argument (pointer to SomeOtherType
) and returns nothing.