开发者

write to ostream inside of function with c++

consider the following function:

void w开发者_如何学JAVAriter(ofstream &output) {
output << "a string to write" << endl;

}

but when i try to call this, i get an error that '<<' is not defined. how can I fix this?


Add #include <fstream> or change ofstream to ostream

Most likely you lack an include, so that ofstream is only forward declared.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜