开发者

write to ostream inside of function with c++

开发者 https://www.devze.com 2023-02-16 03:10 出处:网络
consider the following function: void w开发者_如何学JAVAriter(ofstream &output) { output << \"a string to write\" << endl;

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

精彩评论

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