#include <iostream> #include <sstream> using namespace std; int main() { stringstream ret; ret << "I love you"; cout << ret.str() << endl; //把stringstream类型转换为string类型 return 0; }