problem rombu zaprojektować przykład dziedziczenia bazowego (+diagram) #include #include using namespace std; class radiofm { public: int kompresja; int crc; string format; radiofm(int kompresja, int crc, string format) : kompresja(kompresja), crc(crc), format(format) { cout << "Radio FM" << endl; } virtual void dekoduj() { cout << "Dekodowanie radiofm" << endl; } virtual void wypisz_format() { cout << format << endl; } }; class MPG { public: int kompresja; int crc; string format; MPG(int kompresja, int crc, string format) : kompresja(kompresja), crc(crc), format(format) { cout << "MPG" << endl; } virtual void dekoduj() { cout << "Dekodowanie MPG" << endl; } virtual void wypisz_format() { cout << format << endl; } }; class dab_mp3 { public: int kompresja; int crc; string format; dab_mp3(int kompresja, int crc, string format) : kompresja(kompresja), crc(crc), format(format) { cout << "dab+ MP3" << endl; } virtual void dekoduj() { cout << "Dekodowanie dab+ MP3" << endl; } virtual void wypisz_format() { cout << format << endl; } }; class dekoder : public radiofm, public MPG, public dab_mp3 { public: dekoder(int kompresja_r, int crc_r, string format_r, int kompresja_m, int crc_m, string format_m) : radiofm(kompresja_r, crc_r, format_r), MPG(kompresja_m, crc_m, format_m), dab_mp3(kompresja_r, crc_r, format_r) { } }; /* int main() { dekoder* pd = new dekoder(10, 16, "radio FM", 20, 32, "MPG"); MPG* pMPG = pd; pMPG->dekoduj(); // wypisuje "Dekodowanie MPG" radiofm* pRFM = pd; pRFM->wypisz_format(); // wypisuje "radioFM" dab_mp3* pDab = pd; cout << pDab->kompresja << endl; // wypisuje "10" int i; cin >> i; } */ #include using namespace std; class MPG { public: void wypisz_format() { cout << "MPG" << endl; } }; class MPG2 : public virtual MPG { public: void wypisz_format() { cout << "MPG2" << endl; } }; class MPG4 : public virtual MPG, public virtual MPG2 { public: void wypisz_format() { cout << "MPG4" << endl; } }; class odtwarzacz : public virtual MPG, public virtual MPG2, public MPG4 { public: void f() {} }; int main() { odtwarzacz* o = new odtwarzacz(); MPG* p1 = o; p1->wypisz_format(); // Wypisuje "MPG" MPG2* p2 = o; p2->wypisz_format(); // Wypisuje "MPG2" MPG4* p3 = o; p3->wypisz_format(); // Wypisuje "MPG4" int i; cin >> i; }