writing in binary file in c++

Hi folks, I had created a class for student. This is the class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 &);
};


This is my add method to write a record in the binary file.
1
2
3
4
5
6
7
int student::add(const student &s,fstream &fp)
{
        fp.seekp(0, ios::end);
        if(fp.write((char*)&s,sizeof s))
            return 1;
        return 0;
}

If i write the values of the object s, What are the values written to the file. Is it only rollno, marks and name (Data members only ?). Now i want to add a member for fstream. after adding the member, if i write the file, what data will write into the file (will the fstream values also write to file?)
Topic archived. No new replies allowed.