#include <iostream>
#include <vector>
using namespace std;
struct Composer {
string name;
};
class MusicalComposition {
string title;
Composer composer;
int year;
MusicalComposition(string title, string composerName, int year) {
this->title = title;
this->composer->name = composerName;
this->year = year;
}
void display() {
cout << "MusicanComposer = {"
<< "title = " << this->title << ", "
<< "composerName = " << this->composer->name << ", "
<< "year = " << this->year << "}" << endl;
}
};
class NationalAnthem : public MusicalComposition {
vector<string> anthemNames;
NationalAnthem(string title, string composerName, int year, vector<string> anthemNames) : MusicalComposition(title, composerName, year) {
this->anthemNames = anthemNames;
}
void display() {
cout << "NationalAnthem = {"
<< "title = " << this->title << ", "
<< "composerName = " << this->composer->name << ", "
<< "year = " << this->year << ", "
<< "anthemNames" << this->anthemNames << "}" << endl;
}
}
int main() {
MusicalComposition m("Some title", "John", 2021);
m.display();
return 0;
}
Comments
Leave a comment