我想请教一下指针在C++C++指针功能,初学者问
我有一些简单的代码:
int add(int a, int b){
return a+b;
}
int runner(int x,int y, int (*functocall)(int, int)){
return (*functocall)(x,y);
}
现在,假设我把使用这样的功能:
cout<<runner(2,5,&add);
也许
cout<<runner(2,5,add);
有什么区别?因为当我尝试时,结果是一样的,没有错误。
非常感谢
所以你的意思是,第二个电话是正确的? – BobAlmond 2010-04-06 17:20:45
不,我的意思是说,编译器解析了对函数指针的调用,这实际上是一个语法偏好问题。 – 2010-04-06 17:22:44