#include using namespace std; class KFZ { protected: string marke; int kmstand; }; class Auto : public KFZ { private: int passagiere; public: Auto() { cout << "Neues Auto wird erstellt." << endl; cout << "Marke: "; cin >> marke; cout << "Passagiere: "; cin >> passagiere; } void einsteigen(int personen) { passagiere += personen; } void ausgabe() { cout << "Marke: " << marke << endl; cout << "Passagiere: " << passagiere << endl; } }; class LKW : public KFZ { private: float tonnen; public: LKW() { cout << "Neuer LKW wird erstellt." << endl; cout << "Marke: "; cin >> marke; cout << "Tonnen: "; cin >> tonnen; } void beladen(float gewicht) { tonnen += gewicht; } void ausgabe() { cout << "Marke: " << marke << endl; cout << "Tonnen: " << tonnen << endl; } }; int main() { Auto autos[3] = Auto(); LKW lkws[2] = LKW(); int personen; float gewicht; cout << endl << endl; for(int i = 0; i<3; i++) { cout << "Auto Nr. " << i+1 << endl; cout << "Anzahl Personen die einsteigen: "; cin >> personen; autos[i].einsteigen(personen); } for(int i = 0; i<2; i++) { cout << "LKW Nr. " << i+1 << endl; cout << "Beladen des LKWs. Gewicht in Tonnen angeben: "; cin >> gewicht; lkws[i].beladen(gewicht); } cout << endl << endl; for(int i = 0; i <3; i++) { cout << "Ausgabe Auto Nr. " << i+1 << endl; autos[i].ausgabe(); } for(int i = 0; i <2; i++) { cout << "Ausgabe LKW Nr. " << i+1 << endl; lkws[i].ausgabe(); } system("pause"); return 0; }