Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5707853
  • 博文数量: 675
  • 博客积分: 20301
  • 博客等级: 上将
  • 技术积分: 7671
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-31 16:15
文章分类

全部博文(675)

文章存档

2012年(1)

2011年(20)

2010年(14)

2009年(63)

2008年(118)

2007年(141)

2006年(318)

分类: C/C++

2006-10-12 21:39:30

实际上是一个例子,可是编译的时候没有通过。
很简单的一个问题:
#include 
#include 
int main()
{
        using boost::lexical_cast;
        int a = lexical_cast("123");
        double b = lexical_cast("123.12");
        std::cout<        std::cout<        return 0;
}

wangyao@fisherman:~/temp/boost$ g++ stoi.cpp
stoi.cpp: In function ‘int main()’:
stoi.cpp:7: error: ‘boost::lexical’ has not been declared
stoi.cpp:9: error: ‘lexical_cast’ was not declared in this scope
stoi.cpp:9: error: expected primary-expression before ‘int’
stoi.cpp:9: error: expected ‘,’ or ‘;’ before ‘int’
stoi.cpp:10: error: expected primary-expression before ‘double’
stoi.cpp:10: error: expected ‘,’ or ‘;’ before ‘double’

可以判断是名字空间的问题,改呗~~~

#include 
#include 
using namespace boost;
using namespace std;

int main()
{
        int a = lexical_cast("123");
        double b = lexical_cast("123.12");
        cout<         cout<         return 0;
}

再进行编译,OK~
阅读(1507) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~