Chinaunix
标题:
问大家各关于函数指针转化的问题
[打印本页]
作者:
syiaedonghui
时间:
2007-12-20 08:42
标题:
问大家各关于函数指针转化的问题
// 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呢,谢谢了
作者:
SirFang
时间:
2007-12-20 09:05
提示:
作者被禁止或删除 内容自动屏蔽
作者:
SirFang
时间:
2007-12-20 09:13
提示:
作者被禁止或删除 内容自动屏蔽
作者:
syiaedonghui
时间:
2007-12-20 09:32
o.明白了,谢谢你的答复。
作者:
rriee
时间:
2007-12-20 13:51
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2