Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef STUDENT_H
- #define STUDENT_H
- #include <cstdlib>
- #include <string>
- #include "Course.h"
- namespace ns_student
- {
- class Student
- {
- public:
- Student( const std::string& init_data = std::string( ), Student* init_link = NULL )
- {
- studentName = init_data;
- link_field = init_link;
- course_field = new Course;
- std::cout << "Student Constructor course list test: " << course_field->name() << std::endl;
- }
- // Member functions to set the data and link fields:
- void set_data(const std::string& new_data) { studentName = new_data; }
- void set_link(Student* new_link) { link_field = new_link; }
- // Constant member function to retrieve the current data:
- std::string data( ) const { return studentName; }
- // Two slightly different member functions to retreive
- // the current link:
- const Student* link( ) const { return link_field; }
- Student* link( ) { return link_field; }
- void printCourses();
- private:
- Course* course_field;
- std::string studentName;
- Student* link_field;
- };
- #endif
- void Student::printCourses()
- {
- //for (; course_field; course_field = course_field->link())
- cout << course_field->name() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment