Question: c ++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

c ++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 is currently enrolled in

classList A dynamic array of strings used to store the names of the classes that the student is enrolled in

Write appropriate constructor(s), mutator, and accessor methods for the class along with the following:

A method that inputs all values from the user, including the list of class names. This method will have to support input for an arbitrary number 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.

 

Sample output (bolded text denote input from user)

Enter student name:

Eric

Enter number of classes:

2

Enter name of class 1:

C++

Enter name of class 2:

C

Student 1's data:

Name: Eric

Number of classes: 2

Class 1:C++

Class 2:C

Student 2's data after assignment from student 1:

Name: Eric

Number of classes: 2

Class 1:C++

Class 2:C

Student 1's data after reset:

Name: Eric

Number of classes: 0

Student 2's data, should still have original classes:

Name: Eric

Number of classes: 2

Class 1:C++

Class 2:C

please use the code provied here to complete the code.

#include #include #include

using namespace std;

class Student { public: Student(); ~Student() //Destructor; void InputData(); // Input all data from user void OutputData(); // Output class list to console void ResetClasses(); // Reset class list //TODO Assignment operator private: string name; int numClasses; string *classList; };

int main() { Student s1, s2;

s1.InputData(); // Input data for student 1 cout << "Student 1's data:" << endl; s1.OutputData(); // Output data for student 1

s2 = s1; cout << "Student 2's data after assignment from student 1:" << endl; s2.OutputData(); // Should output same data as for student 1

s1.ResetClasses(); cout << "Student 1's data after reset:" << endl; s1.OutputData(); // Should have no classes

cout << "Student 2's data, should still have original classes:" << endl; s2.OutputData(); // Should still have original classes

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!