Consider the following class specification below. Write the implementation of th
ID: 3545235 • Letter: C
Question
Consider the following class specification below. Write the implementation of the class destructor. Write the implementation of the class copy constructor. Write the prototype (i.e. the header) of the class destructor. Write the prototype (i.e. header) of a member function to overload the assignment operator (i.e. =). Write the implementation of the overloaded assignment operator to perform a deep copying of the data members of an instance of class StudentTestScores into another instance of the same type.
#include <string>
using namespace std;
class StudentTestScores{
private:
string studentName;
float *testScores; // used to point to an array of test scores
int numTestScores; // number of test scores
public:
// Class default constructor
// Class copy constructor
// Class destructor
//class accessors
//class mutators
// other functions
};
Explanation / Answer
class MyClass {
private:
T1 member1;
T2 member2;
public:
// The default copy assignment operator which assigns an object via memberwise copy
MyClass & operator=(const MyClass & rhs) {
member1 = rhs.member1;
member2 = rhs.member2;
return *this;
}
......
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.