typedef 的几个问题,懂得大神解释一下
typedef void node_proc_fun_t(void*);
typedef int node_comp_fun_t(const void*, const void*);
typedef void node_proc_fun_t(void*);
void foo()
{
cout << "hello,world" << endl;
}
int main()
{
node_proc_fun_t fun = foo;
fun();
}
typedef void node_proc_fun_t(void*);
node_proc_fun_t p_node_proc_fun;
#include <stdio.h>
typedef void node_proc_fun_t(void*);
typedef int node_comp_fun_t(const void*, const void*);
void node_proc_fun(int* ptrInt)
{
printf ("%d\n", *ptrInt);
}
void node_comp_fun(const int* ptrInt , const char* ptrChar)
{
printf ("%d, %s\n", *ptrInt, ptrChar);
}
int main(int argc, char *argv[])
{
node_proc_fun_t *fun1 = NULL;
node_comp_fun_t *fun2 = NULL;
fun1 = node_proc_fun;
fun2 = node_comp_fun;
int i = 10;
char *c = "This is a function.";
fun1(&i);
fun2(&i, c);
return 0;
}
#include <stdio.h>
typedef void node_proc_fun_t(void*);
void proc_jia(void *arg)
{
int tmp = *((int *)arg);
printf("%d + 10 = %d\n", tmp, tmp + 10);
}
void proc_jian(void *arg)
{
int tmp = *((int *)arg);
printf("%d - 10 = %d\n", tmp, tmp - 10);
}
void proc_cheng(void *arg)
{
int tmp = *((int *)arg);
printf("%d * 10 = %d\n", tmp, tmp * 10);
}
void proc_chu(void *arg)
{
int tmp = *((int *)arg);
printf("%d / 10 = %d\n", tmp, tmp / 10);
}
int main(int argc, char **argv)
{
node_proc_fun_t *process[4] = {proc_jia, proc_jian, proc_cheng, proc_chu};
int i = 0, num = 100;
for (i = 0; i < 4; i++)
{
process[i](&num);
}
return 0;
}