首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

在VC6中使用boost1.33.1的lexical_cast编译不能通过的有关问题

2012-03-20 
在VC6中使用boost1.33.1的lexical_cast编译不能通过的问题#includeboost/lexical_cast.hpp#includeiost

在VC6中使用boost1.33.1的lexical_cast编译不能通过的问题
#include   <boost/lexical_cast.hpp>
#include   <iostream>

void   boost_lexical()
{
        using   boost::lexical_cast;
        int   a=10;
        double   b=20;

        a   =   lexical_cast <int> ( "123 ");
        b   =   lexical_cast <double> ( "123.12 ");
        std::cout < <a < <std::endl;
        std::cout < <b < <std::endl;
}
int   main()
{
        boost_lexical();
        return   0;
}
//////////////////////////////////
Compiling...
main.cpp
F:\000\boost\myboost\main.cpp(15)   :   error   C2062:   type   'int '   unexpected
F:\000\boost\myboost\main.cpp(16)   :   error   C2062:   type   'double '   unexpected
Error   executing   cl.exe.

myboost.exe   -   2   error(s),   0   warning(s)
////////////////////////////////////////
为什么不能编译通过呢?哪位大大告诉一生?
我的环境:VC6+SP6+WINXPSP2
另:boost的包含路径已经配置好了的


[解决办法]
#include <boost/lexical_cast.hpp>
#include <iostream>
void boost_lexical()
{
using namespace boost;
int a=10;
double b=20;

a = lexical_cast <int> ( "123 ");
b = lexical_cast <double> ( "123.12 ");
std::cout < <a < <std::endl;
std::cout < <b < <std::endl;
}
int main()
{
boost_lexical();
return 0;
}
[解决办法]
写成 a = boost::lexical_cast <int> ( "123 "); 试试
[解决办法]
也有可能你库没有加对路径
[解决办法]
改为:

//using boost::lexical_cast;
int a=10;
double b=20;

a = boost::lexical_cast <int> ( "123 ");
b = boost::lexical_cast <double> ( "123.12 ");


命名空间与模板特化的问题.

热点排行