We were given a prewritten (mostly) .cc file in which we were to write the implementation for two different functions. I was trying to do this without messing with the header of the function but can't seem to do it unless I am forgetting something since it has been awhile since I've done this.
void NumList::save_to_file(ostream& outs)
I tried using
string filename;
outs.open(filename.c_str());
to open the file but get the error
'std::ostream' has no member name 'open'
Whats the go around with this?
std::ostream
does not haveopen
. It isstd::ofstream
exclusive.outs
.open()
is only available for file streams. You should have yoursave_to_file()
takestd::[x]fstream
depending on whether it's for input, output, or both.save_to_file
signature is provided for you as part of the assignment, it would also be safe to assume that you will be passed a file stream that is already open