可以在未指定文件的情况下声明 fstream,并在以后打开该文件。例如,以下代码创建了 ofstream toFile,以便进行写入。
ofstream toFile; toFile.open(argv[1], ios::out);