Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Rewrite the addStudent function in the Course class in Listing 11.16, Course.cpp Download Course.cppto throw a runtime_error if the number of students exceeds the capacity.
Rewrite the addStudent function in the Course class in Listing 11.16, Course.cpp Download Course.cppto 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.
Please include the output
Please do the code for separate file and show the screenshot of your IDE
IN C++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started