gpt4 book ai didi

c - 在结构中定义函数

转载 作者:太空狗 更新时间:2023-10-29 16:19:04 25 4
gpt4 key购买 nike

我们可以用 C 语言在结构体中定义函数吗?

最佳答案

不,因为函数不是数据。但是您可以在结构内定义函数指针。

struct foo {
int a;
void (*workwithit)(struct foo *);
}

关于c - 在结构中定义函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9871119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com