引用传递。 举例:
#include
#include
using namespace std;
ofstream& function(ofstream &ofs)
{
return ofs;
}
int main()
{
ofstream ofs("in.txt");
function(ofs);
return 0;
}
//最简单的实例
#include
#include
using namespace std;
int main(){
ifstream in("datain.txt");
ofstream out("dataout.txt");
int n;
in>>n;
out<
}
//最简单的实例
#include
#include
using
namespace
std;
int
main(){
ifstream
in("datain.txt");
ofstream
out("dataout.txt");
int
n;
in>>n;
out<
0;
}