在C++中各类型拼接成一个string

推荐使用C++标准库作法:

#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
    int a = 2;
    string b = "abc";
    stringstream ss;
    ss << a << b;
    cout << ss.str() << endl;
    return 0;
}

  

posted @ 2013-06-15 22:38  盗草人  阅读(557)  评论(0编辑  收藏  举报