如何在类中定义输出文件流,以便我不必将它传递给函数。基本上我想要做的是这样的:在类中定义输出文件流
class A {
private:
ofstream otp ;
};
然后在我的构造函数,我只是有otp.open("myfile");
和其他功能我有otp.open("myfile", ios::app);
,但在编译的时候失败了,他说:
../thermo.h(18): error: identifier "ofstream" is undefined
ofstream otp ;
我已确保#include <fstream>
谢谢!
我想在我的每个函数中重新定义'ofstream'并不是什么大事......只是想知道我正在尝试做什么是可能的,可能是为了好奇吧 – Amit