title: c++ Serializing an object containing string and pointer to another object
body: <p><em>This question is part of my University Lab work!</em></p>
  
  <p>I have two classes, <code>student</code> and <code>course</code>. A basic interface for both classes is shown below:</p>
  
  <p><strong>student.h</strong></p>
  
  <pre><code>    class student
      {
      private:
          int id;
          string name;
          int course_count;
  
      public:
          student();
          student * student_delete(int);
          void student_add(int);
          static student * student_add_slot(int);
          int get_id();
          int get_course_count();
          string get_name();
          void set_course_count(int);
          void student_display();
          course * course_records;
          void operator= (const student &amp;);
      };
  </code></pre>
  
  <p><strong>course.h</strong></p>
  
  <pre><code>class course
  {
  private:
      string id;
      short credit_hours;
      string description;
  
  public:
      course();
      course * remove_course(course*, int);
      static course * add_course_slots(course*, int);
      int add_course(course*,int);
      string get_id();
      string get_description();
      void course_display(int);
      short get_credit_hours();
  };
  </code></pre>
  
  <p>I've been asked to write the <strong>student</strong> object (only the member variables) to a file in binary mode. Now I understand I have to serialize the object but I've no idea how should I proceed. I know C++ provides basic serialization for basic types (correct me if I'm wrong) but I've no idea how will I serialize a string and a <strong>course records variable</strong> in <strong>student</strong> object (which is a dynamically allocated array) to a file.</p>
  
  <p>Please ask if you need any extra thing. Thanks!</p>