according to MSDN the typedef syntax is:
typedef type-declaration synonym;
Very easy:
typedef int MY_INT;
But how the heck does the member-function-pointer typedefs comply to this rule?
typedef int (MyClass::*MyTypedef)( int);
100% confusion – the synonym (MyTypedef
) is in the middle?
Can someone please explain what the logical steps are to get from the very easy to understand syntax format of MSDN to the reverse/random/front/last/mixed syntax thing of aboves typedef?
*edit thanks for all the fast answers (and the beautification of my post) :)
the synonym (MyTypedef) is in the middle??
Its not in the middle. Just forget member-function for a while, see how a function pointer is defined:
int (*FuncPtr)(int);
And this is how you would typedef it:
typedef int (*FuncPtr)(int);
Simple! The only difference is, in the typedef FuncPtr
becomes a type, while in the pointer declaration, FuncPtr
is a variable.
Similarly,
int (MyClass::*MyTypedef)( int); //MyTypedef is a variable
And the typedef as:
typedef int (MyClass::*MyTypedef)( int); //MyTypedef is a type!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With