字符串与数值 相互转换

2200阅读 0评论2013-07-03 大见DJ
分类:C/C++

#include
           #include
            #include
            using namespace std;

           //数值转换成字符串
           template

 std::string ValueToSting(const T inData)
            {
                    ostringstream os;
                    std::string str_temp;

                       os.str("");
                        os<                        str_temp = os.str();
                        os.str("");
                        return str_temp;
            }


           //字符串转换成数值

template

void StingToValue(const std::string str_temp, T &outData)
            {
                    istringstream is(str_temp);
                    is>>outData;
            }

上一篇:XML 基础
下一篇:字符串分割函数