第1个回答 2009-07-09
引用传递。 举例:
#include<iostream>
#include<fstream>
using namespace std;
ofstream& function(ofstream &ofs)
{
return ofs;
}
int main()
{
ofstream ofs("in.txt");
function(ofs);
return 0;
}本回答被提问者和网友采纳
第2个回答 2009-07-09
//最简单的实例
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream in("datain.txt");
ofstream out("dataout.txt");
int n;
in>>n;
out<<n;
return 0;
}
第3个回答 2019-02-17
//最简单的实例
#include
<iostream>
#include
<fstream>
using
namespace
std;
int
main(){
ifstream
in("datain.txt");
ofstream
out("dataout.txt");
int
n;
in>>n;
out<<n;
return
0;
}