我的代码如下:
#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;
}
编译器指出int *fp = &next;
需要调试,但是,我没有发现这句话有什么问题。
你能告诉我吗?谢谢你的时间~~
最佳答案
函数指针不像普通指针那样定义
int (*fp)(int)
而你的下一个函数已经在主函数中可见,不需要重新声明它
关于c++ - 为什么我的程序失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4554492/