什么是用C这个奇怪的函数指针声明是什么意思? [英] What does this weird function pointer declaration in C mean?
本文介绍了什么是用C这个奇怪的函数指针声明是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以请解释一下 INT((*美孚(INT)))(INT)
在这呢?
INT(* fooptr)(INT);
INT((*美孚(INT)))(INT); //不能明白这是什么呢。诠释的main()
{
fooptr = foo的(0);
fooptr(10);
}
解决方案
INT((*美孚(INT)))(INT);
本声明富
作为期望一个 INT
输入参数并返回一个指向期望一个函数的函数一个 INT
类型参数并返回 INT
。
要更清楚:
富 - 富
美孚() - 是一个函数
美孚(INT) - 以一个int参数
*美孚(INT) - 返回一个指针
(* foo的(INT))() - 以一个函数
(*美孚(INT))(INT) - 带一个int参数
INT(*富(INT))(INT) - 并返回一个int
这里是同一个很好的解释。
Can anyone please explain what int ((*foo(int)))(int)
in this does?
int (*fooptr)(int);
int ((*foo(int)))(int); // Can't understand what this does.
int main()
{
fooptr = foo(0);
fooptr(10);
}
.
解决方案
int ((*foo(int)))(int);
This declares foo
as a function that expects an int
type argument and returns a pointer to a function that expects an int
type argument and return an int
.
To be more clear:
foo -- foo
foo( ) -- is a function
foo(int) -- taking an int argument
*foo(int) -- returning a pointer
(*foo(int))( ) -- to a function that
(*foo(int))(int) -- takes an int argument
int (*foo(int))(int) -- and returning an int
Here is a good explanation for the same.
这篇关于什么是用C这个奇怪的函数指针声明是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文