给出适当的例子,说明清楚,采纳了以后继续加分,谢绝在网上复制大批量文字和代码
再补充一下。像这样的类怎么写入文件和读出文件;
#include<fstream>
#include<string>
#include<iostream>
using namespace std;
class A
{
private:
float a;
string str1;
string str2;
pubulic:
A(){..}
void fun(){....}
};
class B
{
private:
A type;
int c;
doulble d;
string str3;
string str4;
};
int main()
{ B m;
//以下就是对象m的数据输入,并把m写入文件和从文件读出(重点)
return 0;
}
我现在想知道的是怎样把类B的对象m中的数据正确地写入文件和读出文件(对象m的数据已经通过cin输入了)