【发布时间】:2016-10-21 09:06:25
【问题描述】:
我想知道是否可以将其他结构的函数指向一个结构:
例子:
typedef struct
{
int func(int z)
{
return z * 2;
}
} sta;
typedef struct
{
int(*this.func)(int);
} stah;
int main()
{
sta sa;
stah sah;
sah.func = &sa.func;
return 0;
}
这可能在结构中吗?
【问题讨论】:
-
在您的示例中,您没有使用匿名结构,因为您给它们命名
-
@DenisSheremet 我的错。
-
Here 是可能的解决方案
标签: c++ struct c++14 function-pointers