C++指向函数的指针做函数的形参
来源:互联网 发布:数据缺失 编辑:程序博客网 时间:2024/05/21 12:47
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int fun(const int);
//int fun(const int&,const int&);
int fun(int ,int);
string fun(const string,const string);
int fun(int ,int(*)(int,int));//指向函数的指针做形参
int main()
{ int a,b;
a=10;
b=20;
typedef int (*cmpfun2)(int ,int); //定义一个类型 cmpfun2,指向函数 int (int,int);
// cmpfun1 p1=fun;
cmpfun2 p2=fun; //给指针赋值,指向 int fun(int,int)这个函数
// cout<<fun(5,6)<<endl;
cout<<fun(a,b)<<endl;
//cout<<p1(100,200)<<endl;
cout<<fun("abc","bcd")<<endl;
cout<<fun(100,*p2)<<endl; //调用函数,传递一个指向函数的形参 *p2
system("pause");
return 0;
}
int fun(const int a)
{
return a;
}
int fun(int a,int b)
{
return a+b;
}
//int fun(const int& a,const int& b)
///{
//return a+b;
//}
string fun(const string s1,const string s2)
{
return s1+s2;
}
int fun(int a,int(*p)(int,int))
{
int b=p(300,400);
return a+b;
}
- C++指向函数的指针做函数的形参
- C指向函数指针的函数指针
- c 指向函数的指针
- C语言指针---指向函数的指针
- 指向函数的指针——指向函数的指针作为函数的形参
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- 指向函数的指针
- SERVER-U搭建
- 脱壳+破解
- Window Azure 中控制应用程序池闲置超时
- CSS中背景图片定位方法
- 我的QQ765067442
- C++指向函数的指针做函数的形参
- &与&&区别
- WebService/WCF
- STL中map用法详解
- 应届生
- VS2005使用方法
- wince 6.0 编译 怪现象
- 基于Remoting的远程调用_服务器端实现
- float精度和数值范围