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

Greetings, everybody I already started working in this program. I just need some

ID: 3741954 • Letter: G

Question

Greetings, everybody

I already started working in this program. I just need someone to help me complete this part of the assignment (my program has 4 parts of code: main.cpp; Student.cpp; Student.h; StudentGrades.cpp; StudentGrades.h)

Just Modify only the StudentGrades.h and StudentGrades.cpp files to correct all defect
you will need to provide implementation for the copy constructor, assignment operator, and destructor for the StudentGrades class.

Here are my files:

(1) Main.cpp

#include <iostream>

#include <string>

#include "StudentGrades.h"

using namespace std;

int main()

{

                StudentGrades a;

                StudentGrades b; // object b will be used for the tests that require b = a;

                Student s;

                // Test Case 1

                s = a.getStudentWithHighestGrade();

                // get the student with highest grade at initialization

                std::cout << "Student " << s.getName() << " has highest grade of " << s.getGrade() << std::endl;

                if ((s.getName().compare("No Entry") == 0) && (s.getGrade() == 0))

                                // if the test case is meet then Pass

                                std::cout << "Test Case 1 Passes" << std::endl;

                else // else test case fails

                                std::cout << "Test Case 1 Fails" << std::endl;

                // Test Case 2

               

}

(2) Student.cpp

#include <iostream>

#include <string>

#include "Student.h"

using namespace std;

Student::Student()

{

}

Student::Student(std::string n, int g) : name(n), grade(g)

{}

Student::~Student()

{}

void Student::setName(std::string name)

{

                this->name = name;

}

void Student::setGrade(int g)

{

                grade = g;

}

std::string Student::getName() const

{

                return name;

}

int Student::getGrade() const

{

                return grade;

}

(3) Student.h

#include <iostream>

#include <string>

using namespace std;

#ifndef STUDENT_H

#define STUDENT_H

class Student

{

public:

Student(); // default constructor

Student(std::string n, int g); // constructor

~Student(); // destructor

void setName(std::string name); // mutator function

void setGrade(int g); // mutator function

std::string getName() const; // accessor function

int getGrade() const; // accessor function

private:

std::string name;// holds the student name

int grade;// holds the student grage

};

#endif

(4) StudentGrades.cpp (Modify this part for implementation)

#include <iostream>

#include <string>

using namespace std;

#ifndef STUDENT_H

#define STUDENT_H

class Student

{

public:

Student(); // default constructor

Student(std::string n, int g); // constructor

~Student(); // destructor

void setName(std::string name); // mutator function

void setGrade(int g); // mutator function

std::string getName() const; // accessor function

int getGrade() const; // accessor function

private:

std::string name;// holds the student name

int grade;// holds the student grage

};

#endif

(5) StudentGrades.h  (Modify this part for implementation)

#include <iostream>

#include <string>

#include "Student.h"

#ifndef STUDENTGRADES_H

#define STUDENTGRADES_H

class StudentGrades

{

public:

                StudentGrades(); // default constructor

                ~StudentGrades(); // destructor

                Student getStudentWithHighestGrade() const; // accessor function

                void addStudentRecord(std::string name, int grade);

                void resetList();

private:

                const static int MAX_STUDENTS = 5;

                int numberOfStudents;

                Student *students;

};

#endif

Thank you!!! (:

Explanation / Answer

please give thumbs up, thanks

ADD these in .h file:

StudentGrades& operator = ( const StudentGrades &S);//assignment

StudentGrades(StudentGrades &S);//copy Construction

~StudentGrades();// destructor

ADD these in .cpp file:

StudentGrades::StudentGrades():numberOfStudents(0)

{

students = new Student[MAX_STUDENTS];

}

StudentGrades::StudentGrades( StudentGrades &S):numberOfStudents(S.numberOfStudents), students(S.students)

{

}

StudentGrades & StudentGrades ::operator = ( const StudentGrades &S)

{

this->numberOfStudents=S.numberOfStudents;

this->students= new Student[MAX_STUDENTS];

for(int i=0; i<S.numberOfStudents; i++)

{

this->students[i]=S.students[i];

}

return *this;

}

StudentGrades::~StudentGrades()

{

delete[] students;

}