struct GenInfo {
uint64_t (*next)(struct GenInfo * const);
enum GeneratorType type;
union {
struct GenInfo_Constant constant;
struct GenInfo_Counter counter;
struct GenInfo_Discrete discrete;
struct GenInfo_Exponential exponential;
struct GenInfo_File file;
struct GenInfo_Histogram histogram;
struct GenInfo_HotSet hotset;
struct GenInfo_Zipfian zipfian;
struct GenInfo_Latest latest;
struct GenInfo_Uniform uniform;
} gen;
};
该结构体内的第一行: uint64_t (*next)(struct GenInfo * const); 这一行表示的是什么?
是不是指向下一个该结构体的指针呢?
谢谢。
是一个函数指针。
今天来讨论一下C中的内存管理。
记得上周在饭桌上和同事讨论C语言的崛起时,讲到了内存管理方面
我说所有指针使用前都必须初始化,结构体中的成员指针也是一样
有人反驳说,不是吧,以前做二叉树算法时,他的左右孩子指针使用时难道有初始化吗
那时我不知怎么的想不出理由,虽然我还是坚信要初始化的
过了几天这位同事说他试了一下,结构体中的成员指针不经过初始化是可以用(左子树和右子......
答案就在这里:C语言--结构体中的指针
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。