void (*signal(int, void (*fp)(int)))(int);
Question:
What is 'signal' ?
#include <cstdio>
using namespace std;
void f(int);
void (*pf)(int), (*qf)(int);
void (*hf(int, void(*)(int)))(int);
typedef void (*sighandler_t)(int);
sighandler_t signal(int, sighandler_t);
void f(int a)
{
printf("void f(int %d)\n", a);
}
void (*hf(int _i, void(*_pf)(int)))(int)
{
printf("_i = %d\n", _i);
_pf(_i);
return _pf;
}
sighandler_t signal(int signum, sighandler_t sighandler)
{
printf("signal num = %d\n", signum);
sighandler(signum);
return sighandler;
}
int main()
{
pf = &f;
qf = hf(12, pf);
qf(23);
signal(54, f);
return 0;
}
void (*signal(int, void (*)(int)))(int);
Answer:signal is a function, passing {
an int and
a pointer [to a function passing an int returning nothing (void)]},
returning {
a pointer [to a function passing an int returning nothing (void)]}.
posted on 2011-08-31 13:07
wolf5x 阅读(196)
评论(0) 编辑 收藏 引用 所属分类:
c/c++