Question: c++ Rewrite the addStudent function in the Course class to throw a runtime_error if the number of students exceeds the capacity. Also, complete coding the
Rewrite the addStudent function in the Course class to throw a runtime_error if the number of students exceeds the capacity. Also, complete coding the function dropStudent.
#include#include "Course.h" using namespace std; Course::Course(const string& courseName, int capacity){ numberOfStudents = 0; this->courseName = courseName; this->capacity = capacity; students = new string[capacity]; } Course::~Course(){ delete [] students; } string Course::getCourseName() const{ return courseName; } void Course::addStudent(const string& name){ students[numberOfStudents] = name; numberOfStudents++; } void Course::dropStudent(const string& name){ // Complete this code here } string* Course::getStudents() const{ return students; } int Course::getNumberOfStudents() const{ return numberOfStudents; }
NOTE: Be sure to submit "all" files that I may need to test your code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
