This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: xRedactedx on Sep 30th, 2012  |  syntax: C++  |  size: 3.27 KB  |  views: 59  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #ifndef STUDENT_H
  2. #define STUDENT_H
  3.  
  4. #include "Course.h"
  5. #include <string>
  6. class Course;
  7. namespace ns_student
  8. {
  9.         class Student
  10.         {
  11.         public:
  12.                 void set_name( std::string _name ) { name = _name; }
  13.                 std::string get_name() { return name; }
  14.  
  15.                 ~Student();
  16.                 Student();
  17.                 Student( std::string );
  18.  
  19.         private:
  20.                 std::string name;
  21.                 Course *head_ptr;
  22.  
  23.         };
  24. }
  25.  
  26. #endif
  27.  
  28. ---------------------------------------------------------
  29. #ifndef COURSE_H
  30. #define COURSE_H
  31.  
  32. #include <string>
  33. #include "Student.h"
  34.  
  35. class Student;
  36.  
  37. namespace ns_student
  38. {
  39.         class Course
  40.         {
  41.         public:
  42.                 Course* link() { return linkField; }
  43.                 const Course* link() const { return linkField; }
  44.                 void set_link( Course* _linkField ) { linkField = _linkField; }
  45.  
  46.                 void set_courseName( std::string _courseName ) { courseName = _courseName; }
  47.                 std::string get_courseName() const { return courseName; }
  48.                 void set_courseUnits( double _courseUnits ) { courseUnits = _courseUnits; }
  49.                 double get_courseUnits() const { return courseUnits; }
  50.                 void set_courseGrade( double _courseGrade ) { courseGrade = _courseGrade; }
  51.                 double get_courseGrade() const { return courseGrade; }
  52.  
  53.                 ~Course();
  54.                 Course( std::string, double, double, Course* );
  55.        
  56.  
  57.         private:
  58.                 std::string courseName;
  59.                 double courseUnits, courseGrade;
  60.                 Course *linkField;
  61.         };
  62.  
  63.         //Functions for linked list toolkit.
  64.         //std::size_t list_length( const node* head_ptr);
  65.  
  66.  
  67.  
  68.         //Problem is a type mismatch with these functions.
  69.         void list_head_insert( Course*& head_ptr, const Course& entry );
  70.         void list_head_insert( Student*& head_ptr, const Student& entry );
  71.  
  72.  
  73.  
  74.         //void list_insert( Course* previous_ptr, Course& entry );
  75.         template <class Item>
  76.         Item* list_search( Item* head_ptr, const Item& target );
  77.         template <class Item>
  78.         const Item* list_search( const Item* head_ptr, const Item& target );
  79.         //Course * list_locate( Course* head_ptr, std::size_t position );
  80.         //const Course list_locate( const Course* head_ptr, std::size_t position );
  81.         template <class Item>
  82.         void list_head_remove( Item*& head_ptr );
  83.         template <class Item>
  84.         void list_remove( Item* previous_ptr );
  85.         template <class Item>
  86.         void list_clear( Item*& head_ptr );
  87.         //void list_copy( const Course* source_ptr, node*& head_ptr, node*& tail_ptr );
  88.  
  89. }
  90.  
  91. #endif
  92. -----------------------------------------------------------------------------------
  93. #ifndef RECORDS_H
  94. #define RECORDS_H
  95. #include "Student.h"
  96. #include "Course.h"
  97. #include <string>
  98.  
  99. namespace ns_student
  100. {
  101.         class Records
  102.         {
  103.         public:
  104.                 void add_student( std::string, std::string, double, double );
  105.                 ~Records();
  106.                 Records();
  107.         private:
  108.                 Student *records_ptr;
  109.         };
  110. }
  111.  
  112. #endif
  113. ----------------------------------------------------------------
  114. Records.cpp
  115.  
  116. #include "Records.h"
  117.  
  118. namespace ns_student
  119. {
  120.         void Records::add_student( std::string _studentName, std::string _courseName, double _units, double _grade)
  121.         {
  122.                 Student *newStudent = new Student;
  123.  
  124.                 //The problem is a mismatch of types from this function and the function
  125.                 //declaration in the linked list toolkit portion of my Course.h. I can't
  126.                 //figure out why it's a mismatch.
  127.                 list_head_insert( records_ptr, newStudent );
  128.  
  129.         }
  130.  
  131.         Records::~Records()
  132.         {
  133.                 delete records_ptr;
  134.         }
  135.  
  136.         Records::Records()
  137.         {
  138.                 records_ptr = new Student;
  139.         }
  140. }
clone this paste RAW Paste Data