c++如何在文件里存储类对象?
c++如何在文件里存储类对象?
日期:2016-06-29 19:13:27 人气:1
ofstream outfile("test.txt",ios::binary);
outfile.write((char *)t,sizeof(t));
outfile.close();
ifstream infile("test.txt",ios::binary);
infile.read((char *)&t,sizeof(t));
//去掉上面一句中的 & 号即可.改为
//infile.r