How can I define an output file stream within a class, so that I don’t have to keep passing it around to functions. Basically what I want to do is this:
class A {
private:
ofstream otp ;
};
Then in my constructor, I simply have otp.open("myfile"); and in other functions I have otp.open("myfile", ios::app); , but it fails during compile time, saying:
../thermo.h(18): error: identifier "ofstream" is undefined
ofstream otp ;
I have made sure to #include <fstream>
Thanks!
You’ll need to use the fully qualified name,
std::ofstream.