开发者

how to Solve the error C2205(cannot initialize extern variables with block scope)

int inc(int a)
{
    return (++a);
}
int Multi (int *a, int *b, int *c)
{
    return (*c = *a**b);
}


typedef  int(FUNC1) (int in);
typedef  int(FUNC2) (int *, int *, int *);

void Show (FUNC2 fun, int arg1, int *arg2)
{
    FUNC1 p = &inc; //this sentence can't access a pointer of a function
    int temp = p(arg1);
    fun (&temp, &arg1, arg2);
    cout<<(*arg2)<<endl;
}

int _tmain(int argc, 开发者_JAVA百科_TCHAR* argv[])
{
    int a;
    Show(Multi,10,&a);
    return 0;
}


You have declared your function pointer typedefs wrong. Try this:

typedef  int(*FUNC1) (int);
typedef  int(*FUNC2) (int *, int *, int *);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜