#include #include #include class Artwork { public: Artwork(const std::string& author, const std::string& title, int birthYear, const std::string& category) : author(author), title(title), birthYear(birthYear), category(category) {} virtual void displayInfo() const { std::cout << "Author: " << author << ", Title: " << title << ", Birth Year: " << birthYear << ", Category: " << category; } virtual ~Artwork() = default; private: std::string author; std::string title; int birthYear; std::string category; }; class Painting : public Artwork { public: Painting(const std::string& author, const std::string& title, int birthYear, const std::string& category, const std::string& size) : Artwork(author, title, birthYear, category), size(size) {} void displayInfo() const override { Artwork::displayInfo(); std::cout << ", Size: " << size; } private: std::string size; }; class Music : public Artwork { public: Music(const std::string& author, const std::string& title, int birthYear, const std::string& category, const std::string& content) : Artwork(author, title, birthYear, category), content(content) {} void displayInfo() const override { Artwork::displayInfo(); std::cout << ", Content: " << content; } private: std::string content; }; class Chamber : public Music { public: Chamber(const std::string& author, const std::string& title, int birthYear, const std::string& content, int numPerformers) : Music(author, title, birthYear, "Chamber", content), numPerformers(numPerformers) {} void displayInfo() const override { Music::displayInfo(); std::cout << ", Number of Performers: " << numPerformers; } private: int numPerformers; }; int main() { std::vector artworks; artworks.push_back(new Painting("Artist", "Painting", 2020, "Painting", "30x40")); artworks.push_back(new Music("Composer", "Music", 2021, "Music", "Symphony")); artworks.push_back(new Chamber("Composer", "Chamber", 2022, "Quartet", 4)); for (const auto& artwork : artworks) { artwork->displayInfo(); std::cout << std::endl; } for (const auto& artwork : artworks) { delete artwork; } return 0; }