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!

drigoSkalWalker
  • 2,742
  • 9
  • 32
  • 45

2 Answers2

5

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
  • 97,545
  • 26
  • 194
  • 236
0

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

What is a trampoline function?

Community
  • 1
  • 1
jim mcnamara
  • 16,005
  • 2
  • 34
  • 51