首页 > 代码库 > C++ 数组指针
C++ 数组指针
1 #include<iostream> 2 using namespace std; 3 double calculate(double x ,double y ,double (*pf[3])(double,double)); 4 double add(double x ,double y); 5 double att(double x ,double y); 6 double app(double x ,double y); 7 int main() 8 { 9 double (*ps[3])(double,double)={add,att,app};10 double a ,b;11 cout<<"Enter a X : "<<endl;12 cin>>a;13 cout<<"Enter a Y : "<<endl;14 cin>>b;15 double tal = 0.0;16 for(int i=0;i<3;i++)17 {//calculate(a,b,(double(**)(double,double)));18 //需要注意这里19 tal = calculate(a,b,(double(**)(double,double))(ps+i));20 cout<<tal<<endl;21 }22 return 0;23 }24 25 double calculate(double x ,double y ,double (*pf[3])(double,double))26 {27 double temp = 0.0;28 temp = (*pf)(x,y);29 return temp;30 }31 32 double add(double x ,double y)33 {34 return x+y;35 }36 37 double att(double x ,double y)38 {39 return x*y;40 }41 42 double app(double x ,double y)43 {44 return x/y;45 }
C++ 数组指针
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。