72.函数模板指针与类函数模板的绑定

 1 #include <iostream>
 2 #include <functional>
 3 using namespace std;
 4 using namespace std::placeholders;
 5 
 6 template <typename T>
 7 void show(T t)
 8 {
 9     cout << t << endl;
10 }
11 
12 class MyClass
13 {
14 public:
15     template <class T>
16     void show(T t)
17     {
18         cout << t << endl;
19     }
20     void run()
21     {
22         show(123);
23     }
24 };
25 
26 void main()
27 {
28     //函数模板指针
29     /*void(*p)(int i) = show<int>;
30     p(10);*/
31     //调用类函数模板
32     /*MyClass my;
33     my.show(1234);*/
34     MyClass my;
35     auto fun = bind(&MyClass::show<int>, &my, _1);
36     fun(12);
37     system("pause");
38 }

 

转载于:https://www.cnblogs.com/xiaochi/p/8574421.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值