2016-06-13 43 views
0

我正在爲學校項目工作,我必須寫一些行到一個txt文件。沒有什麼不尋常的,但問題來了。當我嘗試通過函數中的參數輸入輸出文件名時,它表示沒有用於調用的匹配函數。讓我告訴你我的代碼:Ofstream拒絕輸入參數

bool save(vector<City*> city, string output){ 
    ofstream dat(output); // ... here comes the problem 
} 

如果有人知道這裏有什麼問題以及如何使其工作,我會很高興。 感謝

回答

1

你要麼啓用-std=c++11編譯器選項,或使用ofstream dat(output.c_str());

查看可用std::ofstream constuctors的參考文檔。

+0

ofstream dat(output.c_str());
,幫助謝謝:) – lucian24

+0

@ lucian24我認爲這兩個選項應該同樣好。 –

+0

是的,但我不知道如何在eclipse中啓用C++ 11,所以我只使用第二個 – lucian24