函数指针
来源:互联网 发布:用友网络股份有限公司 编辑:程序博客网 时间:2024/05/21 19:26
int fun(int a, int b)
{
return a+b;
}
int main()
{
int(*fp1)(int, int) = fun;
cout<<fp1(1,2)<<endl;
typedef int(*Fp2)(int, int);
Fp2 fp2 = fun;
cout<<fp2(1,2)<<endl;
//////////////////////////////////////////////////////////////////////////
std::function<int(int, int)>fp3 = fun;
cout<<fp3(2,4)<<endl;
typedef std::function<int (int, int)>Fp3;
Fp3 fp3 = fun;
cout<<fp3(1,2)<<endl;
//////////////////////////////////////////////////////////////////////////
std::function<int(int, int)>fp4 = std::bind(fun,std::placeholders::_1,std::placeholders::_2);
cout<<fp4(1,2)<<endl;
typedef std::function<int(int, int)>Fp4;
Fp4 fp4 = std::bind(fun,std::placeholders::_1,std::placeholders::_2);
cout<<fp4(1,2)<<endl;
return 0;
}
{
return a+b;
}
int main()
{
int(*fp1)(int, int) = fun;
cout<<fp1(1,2)<<endl;
typedef int(*Fp2)(int, int);
Fp2 fp2 = fun;
cout<<fp2(1,2)<<endl;
//////////////////////////////////////////////////////////////////////////
std::function<int(int, int)>fp3 = fun;
cout<<fp3(2,4)<<endl;
typedef std::function<int (int, int)>Fp3;
Fp3 fp3 = fun;
cout<<fp3(1,2)<<endl;
//////////////////////////////////////////////////////////////////////////
std::function<int(int, int)>fp4 = std::bind(fun,std::placeholders::_1,std::placeholders::_2);
cout<<fp4(1,2)<<endl;
typedef std::function<int(int, int)>Fp4;
Fp4 fp4 = std::bind(fun,std::placeholders::_1,std::placeholders::_2);
cout<<fp4(1,2)<<endl;
return 0;
}
- 指针函数 函数指针
- 函数指针/指针函数
- 指针函数&函数指针
- 函数指针 指针函数
- 函数指针 指针函数
- 指针函数,函数指针
- 函数指针,指针函数,
- 指针函数,函数指针
- 函数指针 指针函数
- 函数指针、指针函数
- 指针函数&函数指针
- 函数指针 指针函数
- 函数指针 指针函数
- 函数指针&指针函数
- 指针函数 函数指针
- 指针函数 &函数指针
- 函数指针&指针函数
- void指针 函数指针
- Makefile 中:= ?= += =的区别
- 关于MFC的document/view结构
- spin lock与 mutexs
- HDU--杭电--2141--Can you find it?--二分
- Ehcache知识点充能
- 函数指针
- 《黑马程序员》java异常知识梳理
- 农业银行取消短信提醒 消息服务步骤
- OpenSSL公钥私钥加密解密程序
- C#中的多态
- Codeforces Round #214 (Div. 2) C. Dima and Salad
- 后台架构
- Tomcat部署web项目+花生壳配置实现外网访问
- asp.net webservice返回json