gpt4 book ai didi

c++ - 如何声明函数 返回指向函数的指针 返回指向 int[3] 的指针

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:06:32 26 4
gpt4 key购买 nike

我正在尝试以下声明:

int (*(*((*foo)(const void *))()))[3];

int (*(*(*foo)(const void *)()))[3];

但是编译器给我一个错误:

error: 'foo' declared as function returning a function

DEMO

在 C++ 中有可能吗?

最佳答案

像这样:

int (*(*f())())[10];

甚至更清洁(有点):

using array_type = int (*)[10];
using return_type = array_type (*)();

return_type f();

关于c++ - 如何声明函数 返回指向函数的指针 返回指向 int[3] 的指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25840836/

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