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.

C++ Two code. You must write the indicated functions into the file

---------------------------------------------------------------------------------------------------------------------

testScore.cpp. This needs No changes.

// This program demonstrates the overloaded = operator // the destructor, and the copy constructor. #include #include "StudentTestScores.h" using namespace std;

//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 using namespace std;

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

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!