#include <iostream>
using namespace std;
int fun(int *)
{
cout<<"Hello World";
return 0;
}
int main()
{
// int(*(*func)[5])(int *); this int (* (*)[5])(int*)类型
// int(*)(int *)
// (*func)[5]
typedef int(*ptr_fun)(int *);
typedef ptr_fun ptr_arr[5];
typedef int(*(*func)[5])(int *);
ptr_arr ptr = {&fun,fun,fun,fun,fun};
func func_ptr = &ptr;
for (int i = 0; i < 5; ++i)
{
(*(*func_ptr + i))(NULL);
cout<<endl;
}
// int (*(*func1)(int*))[5]; int (* (*)(int*))[5] 类型
// 指向返回值是int (*)[5]型、参数为int*型的函数
typedef int (*arr_return)[5];
typedef arr_return (*final)(int *);
typedef int (*(*func1)(int*))[5];
func1 tom;
tom = (final)tom; //可以强制类型转化
return 0;
}
验证测试 int (* (*)(int*))[5] 类型
最新推荐文章于 2023-06-25 17:17:45 发布
本文探讨了C++中如何使用函数指针和动态数组,展示了类型转换在定义返回值为函数数组的函数时的应用,以及如何通过函数指针数组实现函数调用。涉及的概念包括`typedef`、`ptr_arr`和`func_ptr`等。

1146

被折叠的 条评论
为什么被折叠?



