xRedactedx

Untitled

Oct 1st, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #ifndef STUDENT_H
  2. #define STUDENT_H
  3. #include <cstdlib>
  4. #include <string>
  5. #include "Course.h"
  6.  
  7. namespace ns_student
  8. {
  9.     class Student
  10.     {
  11.     public:
  12.     Student( const std::string& init_data = std::string( ), Student* init_link = NULL )
  13.     {
  14.         studentName = init_data;
  15.         link_field = init_link;
  16.         course_field = new Course;
  17.         std::cout << "Student Constructor course list test: " << course_field->name() << std::endl;
  18.     }
  19.  
  20.     // Member functions to set the data and link fields:
  21.         void set_data(const std::string& new_data) { studentName = new_data; }
  22.         void set_link(Student* new_link)             { link_field = new_link; }
  23.  
  24.     // Constant member function to retrieve the current data:
  25.     std::string data( ) const { return studentName; }
  26.  
  27.     // Two slightly different member functions to retreive
  28.     // the current link:
  29.     const Student* link( ) const { return link_field; }
  30.         Student* link( )             { return link_field; }
  31.  
  32.     void printCourses();
  33.    
  34.     private:
  35.     Course* course_field;
  36.     std::string studentName;
  37.     Student* link_field;
  38.    
  39.    
  40.     };
  41. #endif
  42.  
  43. void Student::printCourses()
  44.     {
  45.        
  46.         //for (; course_field; course_field = course_field->link())
  47.         cout << course_field->name() << endl;
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment