Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef STUDENT_H
- #define STUDENT_H
- #include "Course.h"
- #include <string>
- class Course;
- namespace ns_student
- {
- class Student
- {
- public:
- void set_name( std::string _name ) { name = _name; }
- std::string get_name() { return name; }
- ~Student();
- Student();
- Student( std::string );
- private:
- std::string name;
- Course *head_ptr;
- };
- }
- #endif
- ---------------------------------------------------------
- #ifndef COURSE_H
- #define COURSE_H
- #include <string>
- #include "Student.h"
- class Student;
- namespace ns_student
- {
- class Course
- {
- public:
- Course* link() { return linkField; }
- const Course* link() const { return linkField; }
- void set_link( Course* _linkField ) { linkField = _linkField; }
- void set_courseName( std::string _courseName ) { courseName = _courseName; }
- std::string get_courseName() const { return courseName; }
- void set_courseUnits( double _courseUnits ) { courseUnits = _courseUnits; }
- double get_courseUnits() const { return courseUnits; }
- void set_courseGrade( double _courseGrade ) { courseGrade = _courseGrade; }
- double get_courseGrade() const { return courseGrade; }
- ~Course();
- Course( std::string, double, double, Course* );
- private:
- std::string courseName;
- double courseUnits, courseGrade;
- Course *linkField;
- };
- //Functions for linked list toolkit.
- //std::size_t list_length( const node* head_ptr);
- //Problem is a type mismatch with these functions.
- void list_head_insert( Course*& head_ptr, const Course& entry );
- void list_head_insert( Student*& head_ptr, const Student& entry );
- //void list_insert( Course* previous_ptr, Course& entry );
- template <class Item>
- Item* list_search( Item* head_ptr, const Item& target );
- template <class Item>
- const Item* list_search( const Item* head_ptr, const Item& target );
- //Course * list_locate( Course* head_ptr, std::size_t position );
- //const Course list_locate( const Course* head_ptr, std::size_t position );
- template <class Item>
- void list_head_remove( Item*& head_ptr );
- template <class Item>
- void list_remove( Item* previous_ptr );
- template <class Item>
- void list_clear( Item*& head_ptr );
- //void list_copy( const Course* source_ptr, node*& head_ptr, node*& tail_ptr );
- }
- #endif
- -----------------------------------------------------------------------------------
- #ifndef RECORDS_H
- #define RECORDS_H
- #include "Student.h"
- #include "Course.h"
- #include <string>
- namespace ns_student
- {
- class Records
- {
- public:
- void add_student( std::string, std::string, double, double );
- ~Records();
- Records();
- private:
- Student *records_ptr;
- };
- }
- #endif
- ----------------------------------------------------------------
- Records.cpp
- #include "Records.h"
- namespace ns_student
- {
- void Records::add_student( std::string _studentName, std::string _courseName, double _units, double _grade)
- {
- Student *newStudent = new Student;
- //The problem is a mismatch of types from this function and the function
- //declaration in the linked list toolkit portion of my Course.h. I can't
- //figure out why it's a mismatch.
- list_head_insert( records_ptr, newStudent );
- }
- Records::~Records()
- {
- delete records_ptr;
- }
- Records::Records()
- {
- records_ptr = new Student;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement