在定义功能结构 [英] Define functions in structs
本文介绍了在定义功能结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们能否在C编程语言结构定义的功能呢?
Can we define functions in structs in C programming language?
推荐答案
没有,因为功能都没有数据。但是,你可以定义一个结构里面的函数指针。
No, as functions are not data. But you can define function pointers inside a struct.
struct foo {
int a;
void (*workwithit)(struct foo *);
}
这篇关于在定义功能结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文