私のC++プロジェクトをコンパイルしているとき、私は理解できません。私のエラーは、以下のこのコードセクションにスローされます。<string int>をファイルに書き込む - 'operator <<'と一致しないものはありません
void twogramsToFile(const map <string,int> twogram, const string outputfile) {
ofstream myfile (outputfile);
for (auto &x : twogram) {
outputfile << x.first << " " << x.second << "\n"; //this line causes the error
}
myfile.close();
}
そして、私が取得エラーメッセージは、このいずれかになります。
no match for ‘operator<<’ (operand types are ‘const string {aka const std::__cxx11::basic_string<char>}’ and ‘const std::__cxx11::basic_string<char>’)
私は< <オペレータは種類に建設のために定義されていたと思いました。
*組み込み型の*のために<<演算子が定義されていると考えました。* - ' 'は組み込みではありません。 –
PaulMcKenzie