I'm not sure if I can understand the use of a typedefs in the pointers to functions context.
andCode:int (*ptrFunc)(int, double); ptrFunc = myFunction;
I can see that the typedef allowed me to declare several objects of the type ptrFunc. That is nice. But...Code:typedef int (*ptrFunc)(int, double); ptrFunc test = myFunction;
The use of typedef here confuses me since this is not the same as the usual typedef type identifier syntax.
Also it seems that typedef here is (shock!) defining a new type (of pointer to a function that returns an int and takes an int and a double as parameters), something that I didn't think typedef could do. It could create a synonym for a type, not define one.
Am I missing some logic that would probably help me understand better why typedef behaves in this way? Also, is it common usage for a typedef to be used in this context, or do pointers to functions rarely need it since there is rarely the need to point to a different function, once the pointer is initialized?



LinkBack URL
About LinkBacks



Now I just need to go easy on this. Just reading about functions that return pointers to functions... the syntax is a killer.