boost helloworlld

原文地址:

使用环境ubuntu g++
安装boost只需要运行
apt-get install libboost-dev libboost-dbg libboost-doc bcp libboost-*
运行完毕就安装完了

第一个例子,是使用boost中的lexical_cast组件的

#include <boost/lexical_cast.hpp>
#include
<iostream>
int main()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.12");
std::cout
<<a<<std::endl;
std::cout
<<b<<std::endl;
return 0;
}

输出:

m@m:~/a$ ./boost
123
123.12

  

保存成文件boost.cc
运行 g++ -g -Wall -O0 boost.cc -o boost
生成执行文件./boost

posted @ 2011-07-19 17:45  wangkangluo1  阅读(344)  评论(0编辑  收藏  举报