读书人

整数int能否转化成string?该怎么处理

发布时间: 2012-06-17 21:02:01 作者: rapoo

整数int能否转化成string?
int a=12
string b="中国"

我上个帖子问题问的不对,我是想把a转化成string,能够实现a+b="12中国",这样的运算,
不知道能否实现!!




[解决办法]

C/C++ code
#include "stdafx.h"#include <sstream>#include <iostream>#include <string>using namespace std;void main(){     int a=12;    string b="中国";ostringstream oss;oss<<a;string c=oss.str();cout<<c<<b<<endl;system("pause");} 

读书人网 >C++

热点推荐