VERIFY EM Note that manual grading will also be performed since some requirement
ID: 3808059 • Letter: V
Question
VERIFY EM Note that manual grading will also be performed since some requirements such as destructor are not test-able through test cases Create a class named Student that has three member variables: name A string that stores the name of the student numClasses An integer that tracks how many courses the student iscurrently enrolled in classList-A dynamic array of strings used to store the names of the classes that the student is enrolled in e Write appropriate constructor(s), mutator, and accessor methods for the class along with the following arbitrary number A method that inputs all values from the user including the list of class names. This method will have to support input for an of classes. A method that outputs the name and list of all courses A method that resets the number of classes to 0 and the classList to an empty list An overloaded assignment operator that correctly makes a new copy of the list of courses. A destructor that releases all memory that has been allocated. int main() Student s1, s2; Input data for student 1 cout "Student 1's data end output data for student 1 s1.outputDataExplanation / Answer
Please find the class Student with all methods:
class Student
{
private string name;
private int numClasses;
private list<string> classList;
public void InputData()
{
string className;
cout << "Enter student name" << endl;
cin >> name;
cout << "Enter number of classes" << endl;
cin >> numClasses;
for(int i=1;i<=numClasses;i++) {
cout << "Enter name class " << i << endl;
cin >> className;
cin >> classList.push_back(className);
}
}
public void OutputData()
{
cout << "Name: " << name << endl;
cout << "Number of classes: " << numClasses<<endl;
for(int i=1;i<=numClasses;i++) {
cout << "class " << i << " "<< classList[i-1] << endl;
}
}
public void ResetClasses()
{
numClasses=0;
classList.clear();
}
void operator=(const Marks &student) {
name = student.m1;
numClasses = student.numClasses;
classList = student.classList;
}
~Student() {
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.