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.
精彩评论