Is there a way to pass output stream as argument like
void foo (std::ofstream dumFile) {}
I tried that but it gave
error : class "std::basic_ofstream<char, std::char_traits<char>>" has no suitable copy constructor
Both istream and ostream provide member functions for repositioning the file-position pointer. These member functions are seekg ("seek get") for istream and seekp ("seek put") for ostream.
If you get an ifstream as parameter, it should be open from the start because you opened it outside your function. Passing a stream and then opening it inside your function does not make sense.
Of course there is. Just use reference. Like that:
void foo (std::ofstream& dumFile) {}
Otherwise the copy constructor will be invoked, but there is no such defined for the class ofstream
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With