1 //强制类型转换 2 #include "stdafx.h" 3 #include4 #include 5 #include 6 7 using namespace std; 8 9 int _tmain(int argc, _TCHAR* argv[])10 {11 string str_int="520"; 12 string str_double="520.2314";13 const double d = 124.45;14 try15 {16 cout << boost::lexical_cast (str_int) << endl;17 cout << boost::lexical_cast (str_double) << endl;//默认精度为618 cout << boost::lexical_cast (d) << endl;19 }20 catch(boost::bad_lexical_cast& e)21 {22 cerr<<"Bad cast:"< <