假设你有:
struct c_struct {
int value;
/* other stuff */
void (* dump)();
};
你想,在某个时候:
c_struct_obj->dump();
我假设您无法实例化一个 c_struct 对象,使其特定的“转储”函数知道其特定的“值”,就像 C++ 方法知道成员变量的方式一样(我想是通过隐式的“this”)?我想我已经知道答案了(“不”)。如果是这样,还有其他以 OOPy 方式使用 C 结构的方法吗?