码迷,mamicode.com
首页 > 其他好文 > 详细

stringstream 类型转换

时间:2018-04-28 19:32:06      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:include   AC   using   space   实现   class   pac   style   std   

stringstream可以吞下不同的类型,然后吐出不同的类型。

这样可以实现int,string,double等类型的转换

 

 1 #include<sstream>
 2 
 3 using namespace std;
 4 
 5 int main()
 6 {
 7         int x;
 8         stringstream temp;
 9     temp << x;//吞入被转换的类型
10         string s1 = temp .str();//吐出需要的类型
11 }
12     

 

stringstream 类型转换

标签:include   AC   using   space   实现   class   pac   style   std   

原文地址:https://www.cnblogs.com/xiaoxue126/p/8969021.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!