单选题
C++
2008-10-06
以下不能正确创建输出文件对象并使其与磁盘文件相关联的语句是( )。
A.ofstream myfile;myfilopen("d:ofiltxt"):
B.ofstream*myfile=new ofstream;myfile->open("d:ofiltxt");
C.ofstream myfile("d:ofiltxt");
D.ofstream*myfile=new("d:ofile:txt");
参考答案
D
答案解析
本题考查文件对象的创建方法。可以直接定义文件对象,也可以用new来动态生成。很明显,选项D中使用new的方式是错误的。
你可能感兴趣的试题
A.A():d(new B)()
B.A(const A&oo):d(new B){*d=*od:}
C.~A(d){}
D.~A(){delete d;}