1. 程式人生 > >boost庫安裝測試

boost庫安裝測試

test.cpp

#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;
}

編譯:
g++ test.cpp -I$BOOST_INCLUDE -L$BOOST_LIB -o test
./test
輸出:
123
123.12