Question: C++ Two code. You must write the indicated functions into the file testScore.cpp. --------------------------------------------------------------------------------------------------------------------- testScore.cpp. This needs No changes. // This program demonstrates the overloaded
C++ Two code. You must write the indicated functions into the file testScore.cpp.

---------------------------------------------------------------------------------------------------------------------
testScore.cpp. This needs No changes.
// This program demonstrates the overloaded = operator // the destructor, and the copy constructor. #include
//Function prototype void displayStudent(StudentTestScore);
int main() { // Create a StudentTestScores object and // assign test scores. StudentTestScore student1("Kelly Thorton", 3); student1.setTestScore(100.0, 0); student1.setTestScore(95.0, 1); student1.setTestScore(80, 2);
// Create another StudentTestScore object // with default test scores. StudentTestScore student2("Jimmy Griffin", 5);
// Assign the student1 object to student2 student2 = student1;
// Display both objects. They should // contain the same data. displayStudent(student1); displayStudent(student2); return 0; }
// The displayStudent function accepts a // StudentTestScores object's data. void displayStudent(StudentTestScore s) { cout
---------------------------------------------------------------------------------------------------------------------
StudentTestScores.h |This is the code that needs to be completed so that it works with the testScore.cpp file
#ifndef STUDENTTESTSCORES_H #define STUDENTTESTSCORES_H #include
const double DEFAULT_SCORE = 0.0;
class StudentTestScore { private: string studentName; //The student's name double* testScores; //Point to array of test scores int numTestScores; //Number of test scores
// Private member function to create an // array of test scores. void createTestScoresArray(int size) { numTestScores = size; testScores = new double[size]; for (int i = 0; i
public: // Constructor StudentTestScore(string name, int numScore) { studentName = name; createTestScoresArray(numScore); }
// Copy constructor // YOU MUST IMPLEMENT THIS FUNCTION StudentTestScore(const StudentTestScore& obj) { // PLACE YOU CODE HERE }
// Destructor // YOU MUST IMPLEMENT THIS FUNCTION ~StudentTestScore() { // PLACE YOU CODE HERE }
// The setTestScore function sets a specific // test score's value. void setTestScore(double score, int index) { testScores[index] = score; }
// Set the student's name. void setStudentName(string name) { studentName = name; }
// Get the student's name. string getStudentName() const { return studentName; }
// Get the number of test scores. int getNumTestScores() const { return numTestScores; }
// Get a specific test score. double getTestScore(int index) const { return testScores[index]; }
// Overloaded = operator // YOU MUST IMPLEMENT THIS FUNCTION const StudentTestScore operator=(const StudentTestScore& right) { // PLACE YOU CODE HERE } }; #endif
The functions that you must write, have a commentary: 11. // PLACE YOUR CODE HERE Once they are implemented, you must compile the files without any error
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
