c struct中使用函数指针
结论:纯C中的struct没有成员函数,但可以有函数指针来模拟实现class成员函数。struct为public 而 class为 private。
++++
拓展关键字:Object-oriented programming with ANSI-C ;回调函数与函数指针
++++
实例:
* typedef struct spooling_field {
* int nm;
* int width;
* const char *name;
* const struct spooling_field *sub_fields;
* int (*read_func) (lListElem *ep, int nm, const char *buffer, lList **alp);
* int (*write_func) (const lListElem *ep, int nm, dstring *buffer, lList **alp);
* } spooling_field;