yfstone

#include <sstream>  //头文件是sstream

string doubleToString(double inValue) const

{

  ostringstream ostr; //创建一个流

  ostr << inValue;  //把值传递如流中

  return ostr.str();

}

 

double stringToDouble(string inString) const

{

  double temp;

  istringstream istr(inString); //从string对象inString中读取字符

  istr >> temp;

  if(istr.fail() || !istr.eof())

  {

    return 0; //设定非数字的字符串值为0

  }

  return temp;

}

  

分类:

技术点:

相关文章: