13-1
#pragma once #ifndef CD_H_ #define CD_H_ class Cd { private: char performers[50]; char label[20]; int selections; double playtime; public: Cd(const char* s1, const char* s2, int n, double x); Cd(const Cd& d); Cd(); virtual ~Cd(); virtual void Report() const; Cd& operator=(const Cd& d); }; class Classic :public Cd { private: char name[20]; public: Classic(const char* s1, const char* s2, const char* s3, int n, double x); Classic(const Classic& d, char* c); Classic(const Classic& d); Classic(); virtual void Report() const; Classic& operator=(const Classic& d); }; #endif // !CD_H_
#include "pch.h" #include <iostream> #include <cstring> #include "cd.h" using namespace std; Cd::Cd(const char* s1, const char* s2, int n, double x) { strcpy_s(performers, s1); strcpy_s(label, s2); selections = n; playtime = x; } Cd::Cd(const Cd& d) { strcpy_s(performers, d.performers); strcpy_s(label, d.label); selections = d.selections; playtime = d.playtime; } Cd::Cd() { performers[0] = '