// Source: "Software Design ...", John A Robinson, Newnes, 2004, page 157. #include using namespace std; #define MAXSTUDENTS 80 #define MAXNAMELENGTH 30 class student { protected: char name[MAXNAMELENGTH]; long id; float mark; public: student(const char *n, const long i, const float m) { strcpy(name, n); id = i; mark = m; } float get_mark() const { return(mark); } virtual void calc_mark() {} }; class a_stream_student : public student { float midterm; float final; public: a_stream_student(const char *n, const long i, const float mid, const float fin) : student(n, i, 0.0) // This is called explicitly here to pass the arguments down { midterm = mid; final = fin; } void calc_mark() { mark = midterm*0.5 + final*0.5; } }; class b_stream_student : public student { float project; float final; public: b_stream_student(const char *n, const long i, const float pro, const float fin) : student(n, i, 0.0) { project = pro; final = fin; } void calc_mark() { mark = project*0.4 + final*0.6; } }; class student_list { protected: student *st[MAXSTUDENTS]; int num_students; public: student_list() { num_students = 0; } // Will be set by load_data ~student_list() { for (int i = 0; i < num_students; i++) delete st[i]; } int load_data(const char *); float average_mark() const; }; class software_design : public student_list { public: software_design() : student_list() {}; int work_out_marks(); };