在.h中
typedef struct
{
   char* name
   int   args;
   double  (*func)();
} FUNCTION;在.cpp中
FUNCTION Funcs[] =
{
   { "sin",     1,    sin },
   { "cos",     1,    cos },
   { "tan",     1,    tan },
.....
};
我想根椐字串name找到函数的地址,FUNCTION 结构中依次为:函数名,参数个数,函数地址
这样我在处理字串比如"sin"时就能通过Funcs找到具体的函数地址。
以前这是一个.c文件,在VC6下编译,好使。
可是文件换成.cpp后在VC6下编译不通过。
错误如下:
error C2440: 'initializing' : cannot convert from '' to 'double (__cdecl *)(void)'
        None of the functions with this name in scope match the target type若把sin,cos等函数前加上&,如下
FUNCTION Funcs[] =
{
   { "sin",     1,    &sin },
   { "cos",     1,    &cos },
   { "tan",     1,    &tan },
.....
};
则会产生以下错误:
error C2440: 'initializing' : cannot convert from 'double (__cdecl *)(double)' to 'double (__cdecl *)(void)'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
这好像离正确很近了,但还是不行。请问我该怎么改代码?