Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Page of 7 ZoOM 4. The following program represents a gradebook in C+ using class

ID: 3904679 • Letter: P

Question

Page of 7 ZoOM 4. The following program represents a gradebook in C+ using classes and member functions. For this question you may NOT use smart pointers. study the pragram, and then correctly add logic to properly cleanup all resources that have been allocated on the heap. 4,7 Structured Dato.md 5/22/2018 #include #include #include using nanespace std class GradeRecord ( public: GradeRecord (int id, double grade) Ch int getId) const return_studentId; :studentld(id), erade(erade) void setérade (double grade) _erade grade;) friend ostrea& operator

Explanation / Answer

here is your solution : ----------->>>>>>>>>

#include<iostream>
#include<vector>

using namespace std;

class GradeRecord{
//same as in question
};

class Gradebook{
public:
  Gradebook(){
   //same as in the question
  }
  ~Gradebook(){
   for(int i = 0;i<_records.size();i++){
    delete _records[i];
   }
  }
  
private:
  vector<GradeRecord*> _records;
};

int main(){
//same as in the question

delete grades;
//this will delete all the GradeRecord by calling the destructor of Gradebook and also the gradebook of main
}