函数指针
小栗子
#include <iostream>
using namespace std;
double f(int c){
return 2*3.14*c;
}
void main(){
typedef double (*Fp)(int);
Fp fp;
fp = f;
double d = (*fp)(5);
cout<<d;
}
#include <iostream>
using namespace std;
double f(int c){
return 2*3.14*c;
}
void main(){
double (*fp)(int);
fp = &f;// 等价于fp=f;
double d = fp(5);//等价于(*fp)(5)
cout<<d;
}
教室好冷>.<要不是要来补查C++作业,我可以在我大仙林的有暖气的教室自习的
上面的有没有取地址符号都不重要,因为本来f就是代表地址信息存储的