我是C++的新手,我試圖讓一個簡單的程序啓動並運行。Stringstream的Str方法不起作用。 (不同類型的連接)(C++)
我在Windows系統上使用Eclipse IDE(C++版本)。
我想連接一個輸出語句,它會結合數字和字符串。
我知道在Java中,這是用System.out.println()方法自動完成的。
我能研究的是在C++中實現這個功能的一個好方法是使用字符串流方法。
#include <iostream>
#include <string>
#include "Person.h"
...
string simpleOutput(){
stringstream ss;
int a = 50; // for testing purposes
int b = 60;
string temp = "Random";
ss << a << b << temp;
return string output = ss.str();
}
當我嘗試編譯這個代碼是得到如下:「方法‘STR’無法解析
我還沒有上找到一個解決方案任何網頁。 牛逼 謝謝!
@Psypher我根本不知道該怎麼做你參考。 OP **不會**使用'stringstream' –
@IvayloStrandjev也許'stringsteam'(缺少'r')? – Angew
我看到「stringsteam」,而不是「stringstream」(或者說它遲到讓我讀到SO)。 – WhozCraig