typedef syntax with (member) function pointers

MSDN states, that the typedef syntax is

typedef type-declaration synonym;

But that’s not the whole truth. If you want to typedef a function pointer or member function pointer, this is wrong:

typedef void(*)(int) myFun;

This is the correct syntax:

typedef void(*myFun)(int);
typedef void(MyClass::*myFun)(int);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.