开发者

Types in a struct in C

开发者 https://www.devze.com 2023-01-02 00:49 出处:网络
In this article : http://publib.boulder.ibm.com/infocenter/macxh开发者_运维技巧elp/v6v81/index.jsp?topic=/com.ibm.vacpp6m.doc/language/ref/clrc03defst.htm

In this article : http://publib.boulder.ibm.com/infocenter/macxh开发者_运维技巧elp/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!


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
};


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消