Question: C++ (The Course class) Revise the Course class implementation in , Course.cpp, as follows: When adding a new student to the course, if the array
C++ (The Course class) Revise the Course class implementation in
, Course.cpp, as follows:
When adding a new student to the course, if the array capacity is exceeded, increase the array size by creating a new larger array and copying the contents of the current array to it.
Implement the dropStudent function.
Add a new function named clear() that removes all students from the course.
Implement the destructor and copy constructor to perform a deep copy in the class.
Write a test program that creates a course, adds three students, removes one, and displays the students in the course.
#1 nclude O Stream 2 #include "Course.h" 3 using namespace std; 5 Course: Course Cconst string& courseName, int capacity) 6 7 numbe rofStudents 0 8 this courseName course Name 9 this capacity capacity 10 students new string capacity] 11 12 13 Course: Course C) 14 15 delete D] students 16 17 18 string Course: agetCounseNameo const 19 200 return course Name 21 22 23 void Course addstudent const string& name) 24 25 students Inumber0fStudents] name 26 number 0fStudents 27 28 29 void Course dropStudentCconst string& name) 30 1 31 Left as an exercise 32 33 34 string* Course: getStudents O const 35 1 36 return students 38 39 int Course getNumberofStudentsC) const 40 41 return numberofStudents 42
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
