函数指针的使用

来源:互联网 发布:php cookie 跨域共享 编辑:程序博客网 时间:2024/05/22 03:43
#include<iostream>
using namespace std;


int max1(int x,int y)
{
return x>y?x:y;
}


int main()
{
int max1(int,int);
int (*f)(int,int)=&max1;//函数指针
int a,b,c,d;
cout<<"Enter three numbers:"<<endl;
cin>>a>>b>>c;
d=(*f)((*f)(a,b),c);
cout<<"The largest number is: "<<d<<endl;
return 0;
}
0 0
原创粉丝点击