r2100

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  8 Posts :: 9 Stories :: 2 Comments :: 0 Trackbacks

常用链接

留言簿(3)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 1 // boost.cpp : 定义控制台应用程序的入口点。
 2 //
 3 
 4 #include "stdafx.h"
 5 
 6 #include <iostream>  
 7 #include <boost/thread/thread.hpp>  
 8 #include <boost/bind.hpp>
 9 #include <boost/function.hpp>
10 void hello(int i, int j)  
11 {  
12     std::cout << "Hello world, I'm a thread!" << std::endl;  
13     std::cout<< i+j << std::endl;
14 }  
15 
16 class A
17 {
18 public:
19     void hello(int i, int j){
20         std::cout<<i+j<<std::endl;
21     }
22 };
23 
24 int _tmain(int argc, _TCHAR* argv[])
25 {
26     //boost::thread thrd(&hello);  
27     //thrd.join(); 
28 // bind
29 //     A a;
30 //     boost::bind(&A::hello, a, 1, 2)(1,2);
31 //     boost::function<void(int,int)> f;
32 
33 // function
34 //     boost::function<void(int,int)> f;
35 //     f = hello;
36 //     f(1,2);
37 
38     A a;
39     boost::function<void(A,intint)> cf;
40     cf=&A::hello;
41     cf(a,1,2);
42 
43 // bind & function    
44 //     boost::function<void(int,int)> f;
45 //     f=boost::bind(hello,_1,_2);
46 //     f(1,1);
47 // 
48 //     A a;
49 //     boost::function<void(int, int)> cf;
50 //     cf=boost::bind(&A::hello,a,_1,_2);
51 //     cf(1,1);
52 // 
53 //     boost::function<>
54 
55     return 0;
56 }
57 
posted on 2015-06-28 23:25 r2100 阅读(99) 评论(0)  编辑 收藏 引用 所属分类: C++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理