为什么我的编程失败?

Dar*_*son 2 c++ debugging

我的代码如下:

#include <iostream>

using std::cout;
using std::endl;

int next(int n)
{
    return n + 1;
}

int main()
{
    int next(int);  // function declaration
    int *fp = &next;

    int temp = 10;
    temp = (*fp)(temp);
    cout << temp << endl;

    return 0;  
}
Run Code Online (Sandbox Code Playgroud)

编译器点int *fp = &next;需要调试,但是,我没有发现这句话有什么问题.你能告诉我吗?谢谢你的时间~~

Dav*_*vid 8

函数指针没有像普通指针那样定义

int (*fp)(int)
Run Code Online (Sandbox Code Playgroud)

并且您的下一个功能已经在main中可见,无需重新声明它