- 论坛徽章:
- 0
|
// test_function_pointer4.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
typedef int ( *FPInt)(int a,int b);
typedef int ( *FPDouble)(double a,double b);
int Compare_int(int a,int b);
int CompareAll(double a,double b,FPDouble fpDouble);
int main(int argc, char* argv[])
{
int a,b;
a = 1;
b = 2;
CompareAll(a,b,(FPDouble)Compare_int);
return 0;
}
int Compare_int(int a,int b)
{
printf("compare int!\n");
printf("a = %d,b = %d\n",a,b);
return NULL;
}
int CompareAll(double a,double b,FPDouble fpDouble)
{
printf("a = %d,b = %d\n",a,b);
fpDouble(a,b);
return NULL;
}
结果为
a = 0,b= 1072693248
compare int
a = 0,b= 1072693248
不为什么不为1呢,谢谢了 |
|