【发布时间】:2011-06-08 02:37:26
【问题描述】:
我在其中一个函数中初始化并打开了一个文件,我应该将数据输出到一个输出文件中。如何将文件作为参数传递,以便可以使用另一个函数将数据输出到同一个输出文件中?例如:
void fun_1 () {
ifstream in;
ofstream outfile;
in.open("input.txt");
out.open("output.txt");
////function operates////
//........
fun_2()
}
void fun_2 () {
///// I need to output data into the output file declared above - how???
}
【问题讨论】: