Chinaunix首页 | 论坛 | 博客
  • 博客访问: 323135
  • 博文数量: 100
  • 博客积分: 2620
  • 博客等级: 少校
  • 技术积分: 920
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-16 02:50
文章分类

全部博文(100)

文章存档

2011年(5)

2010年(12)

2009年(83)

分类:

2009-12-02 17:09:14

boost实用工具tuple

http://www.ibm.com/developerworks/cn/aix/library/au-util_boost_lib/
tuple里面可以放内置类型,也可以放自定义类型,对于自定义类型,如果要调用<<操作,需要重载运算符<<,如下:
#include
#include
#include
#include
using namespace std;
using namespace boost;
class X
{
 int x;
 /*
 
X(const X& u)
 {
  x = u.x;
 }
 */
public:
 X(int y = 5):x(y)
 {}
 friend
ostream& operator <<(ostream& os, const X& u);
};
ostream& operator <<(ostream& os, const X& u)
{
 os<<"{
"< return os;
}
int main()
{
 tuple t(2,'a',0.9);
 tuple t1(2,X(2));
 
cout< cout<
 char arr[] = "hello world";
 tuple t3(8,arr);
 
cout<<"t3:"< t3.get<1>()[0] = 'Y';
 cout<<"t3:"< return 0;
}
阅读(907) | 评论(0) | 转发(0) |
0

上一篇:va函数

下一篇:用C语言扩展Python的功能

给主人留下些什么吧!~~