tags:

views:

86

answers:

2

In this article : http://publib.boulder.ibm.com/infocenter/macxhelp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc03defst.htm

What's means the sentence "In C, a structure member may be of any type except "function returning T" (for some type T)"

Thanks for all the answers!

+5  A: 

In C there are no member functions - you can have pointers to functions as members, but you can't declare or define functions in structures:

struct X {
    int f(); // illegal in C
    int g() { return 42; } // same here
    int (*h)(); // pointer to function, fine
};
Georg Fritzsche
+1, Being able to put a function pointer into a structure makes this limitation not really a limitation at all.
Carl Norum
wow! thanks for your strike, I got it ;D
drigoSkalWalker
nor inline functions???
drigoSkalWalker
@drigo: I don't quite understand, what are you asking?
Georg Fritzsche
A: 

In the same vein - creating containers for functions - have a look at trampolines * (nested functions is another name). I am NOT endorsing nested functions...

http://stackoverflow.com/questions/189725/what-is-a-trampoline-function

jim mcnamara