#include #include using namespace std; class Tier { // class-> members are private by default | struct -> members are public by default // float Einnahme = 0; // 3 globale Variablenen deklarieren und initialisieren private: float Gewicht = 0; float Tagespreis = 0; public: Tier(/**float Einnahme,**/ float Gewicht, float Tagespreis) { // this->Einnahme = Einnahme; this->Gewicht = Gewicht; this->Tagespreis = Tagespreis; } float getEinnahme() { return this->Gewicht * this->Tagespreis; } float getGewicht() { return this->Gewicht; } float getTagespreis() { return this->Tagespreis; } }; Tier* Daten_abfragen() // Deklaration und Definition der Methode Daten_abfragen { float tages_preis = 0, gewicht = 0; cout << "Wie steht der Tagespreis? " << endl; cin >> tages_preis; cout << "Wie ist das Gewicht? " << endl; cin >> gewicht; Tier *tier = new Tier(tages_preis, gewicht); return tier; } void Einnahme_berechnen(Tier *tier) // Deklaration und Definition der Methode Einnahme_berechnen { cout << "Einnahme: " << tier->getEinnahme() << endl; } int main() { Tier *ein_tier; ein_tier = Daten_abfragen(); // Methodenaufrufe Einnahme_berechnen(ein_tier); cout << endl << endl; delete ein_tier; system("PAUSE"); return 0; }