Inheritance Assigment 6 Points each ... Update code for inheritance 1- Decide whether or not you need a copy constructor or assignment operator overload. Tell me why? Code them up if necessary. 2- Create a Classic CD class which inherits from CD and creates a list of the performers primarywork. Overload the report() method to include the primary works. //----------------------------------------------------------------------------- // main.cpp //----------------------------------------------------------------------------- #include using namespace std; #include "cd.h" // which will contain the new Classic cd void show_cd(const CD & disk); int main() { CD c1("Beatles", "Capitol", 14, 35.5); // Classic c2 = Classic("Piano Sonata in B flat, Fantasia in C", // "Alfred Brendel", "Philips", 2, 57.17); CD *pcd = &c1; cout << "Using object directly:\n"; // use CD method c1.report(); // use Classic method // c2.report(); cout << "\nUsing type cd * pointer to objects:\n"; // use CD method for cd object pcd->report(); // use Classic method for classic object // pcd = &c2; // pcd->report(); cout << "\nCalling a function with a CD reference argument:\n"; show_cd(c1); // show_cd(c2); cout << "\nTesting assignment: "; // Classic copy; // copy = c2; // copy.report(); return 0; } void show_cd(const CD & disk) { disk.report(); } #ifndef _CD_H_ #define _CD_H_ //----------------------------------------------------------------------------- // cd.h - base class //----------------------------------------------------------------------------- // represents a CD disk class CD { public: enum { PERFORMER_MAX = 50, LABEL_MAX = 20 }; CD(const char * performers, const char * label, int selections, double playtime); // CD(const CD & d); CD(); virtual ~CD() {} virtual void report() const; // CD & operator=(const CD & d); private: char performers[PERFORMER_MAX]; char label[LABEL_MAX]; int selections; // number of selections double playtime; // playing time in minutes }; // CODE UP the Classic class here //----------------------------------------------------------------------------- // classic.h - derived class //----------------------------------------------------------------------------- // CODE UP THE Classic class here #end #ifndef _CD_CPP_ #define _CD_CPP_ //----------------------------------------------------------------------------- // cd.cpp - CD methods //----------------------------------------------------------------------------- #include #include using namespace std; #include "cd.h" CD::CD(const char * performers, const char * label, int selections, double playtime) { strncpy(performers, this->performers, PERFORMER_MAX - 1); performers[PERFORMER_MAX-1] = '\0'; strncpy(label, this->label, LABEL_MAX-1); label[LABEL_MAX-1] = '\0'; selections = this->selections; playtime = this->playtime; } CD::CD() { performers[0] = '\0'; label[0] = '\0'; selections = 0; playtime = 0.0; } void CD::report() const { cout << "Performer(s): " << performers << '\n'; cout << "Label: " << label << '\n'; cout << "Number of selections: " << selections << '\n'; cout << "Play time: " << playtime << endl; } //----------------------------------------------------------------------------- // CD.cpp - Classic methods //----------------------------------------------------------------------------- // CODE UP THE Classic methods here #endif