输出函数用了形参ofstream &fout,调用函数的时候实参写什么?
void Data::GetYear(ofstream &fout)
{fout<<year<<"-";}
void Data::GetMonth(ofstream &fout)
{
fout << month << "-";
}
void Data::GetDay(ofstream &fout)
{
fout << day;
}
void Employee::show(ofstream &fout)//输出employee基本信息
{
fout << "number:" << num << endl;
fout << "name:" << name << endl;
fout << "sex:" << sex << endl;
fout << "birthday:";
d.GetYear( );//实参填什么
d.GetMonth();//同上
d.GetDay();//同上
fout<< endl;
fout << "post:" << post << endl;
}
也是用ofstream
ofstream ofs("c:\\xxx.dat");
传ofs
也是用ofstream
ofstream ofs("c:\xxx.dat");
传ofs
这函数传递是一个对象引用,你函数里面可以直接使用ofs