标签: c++
考虑以下功能:
void writer(ofstream &output) { output << "a string to write" << endl; }
但是当我试着调用它时,我得到一个'&lt;&lt;'的错误没有定义。我该如何解决这个问题?
答案 0 :(得分:7)
添加#include <fstream>或将ofstream更改为ostream
#include <fstream>
ofstream
ostream
很可能你缺少一个include,所以ofstream只是向前声明。