<分区>
我为学生创建了一个类(class)。这是类(class)。
class student
{
int rollno,marks;
char name[20];
public:
void show();
void get();
int filecreate(const string &,fstream &);
int fileopen(const string &,fstream &);
static int add(const student &,fstream &);
static int read(const student &,fstream &,int);
static int update(const student &,fstream &,int);
int showall(fstream &);
int view(fstream &,int );
int adddummy(fstream &);
};
这是我在二进制文件中写入记录的添加方法。
int student::add(const student &s,fstream &fp)
{
fp.seekp(0, ios::end);
if(fp.write((char*)&s,sizeof s))
return 1;
return 0;
}
如果我写入对象 s 的值,写入文件的值是什么。是否只有 rollno、marks 和 name(仅限数据成员?)。现在我想为 fstream 添加一个成员。添加成员后,如果我写入文件,将写入文件的数据是什么(fstream 值是否也会写入文件?)