【发布时间】:2012-02-18 03:10:09
【问题描述】:
如果您将 fstream 声明为类的成员,您可以使用什么构造函数来实例化它?
#include <fstream>
class Foo {
Foo();
// not allowed
std::fstream myFile("\\temp\\foo.txt", fstream::in | fstream::out | fstream::trunc);
// allowed
std::fstream myFile;
}
// constructor
Foo::Foo() {
// what form of myFile("\\temp\\foo.txt", fstream::in | fstream::out | fstream::trunc) can I use here?
myFile = ???
}
【问题讨论】: