The class below is only partially complete. Complete the class (you only need to
ID: 3832631 • Letter: T
Question
The class below is only partially complete. Complete the class (you only need to write function definitions) to do two things: (1) Make the class work with main where the (), where the "cpp" variable should be a class of 240 students called "csci-1113 001", (2) Not leak any memory. struct UoMStudents {string name; string grade;}; class UoMClass {private: string className; int class Size; UoMStudents *students;//dynamic array of students public://blank right now...}; int main () UoMClass cpp(240, "csci-1113-001");}Explanation / Answer
#include <iostream>
using namespace std;
struct UoMStudents{
string name;
string grade;
};
class UoMClass{
string className;
int classSize;
UoMStudents *students;
public:
// constructor
UoMClass(int size, string name){
classSize =size;
className = name;
students = new UoMStudents[classSize];
}
// destructor
~UoMClass(){
delete [] students;
}
};
int main(){
UoMClass cpp(240, "csci-1113-001");
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.