C++如何把类里的私有成员数据保存到文件里啊

如题
2025-04-13 04:03:36
推荐回答(1个)
回答1:

ofstream outfile("d:\\data\\f1.txt", ios::out);//对象与文件的关联,并指定工作模式, 默认
if (!outfile)
{
cerr << "open file error!" << endl;
abort();
}

outfile << p.name<

outfile.close();