int main() { int counter = 0; while (counter != 2) { std::unique_ptr<Automat> device_ptr(new Automat); vector<Automat> Vdevice(2); Automat device; // Initialisieren device_ptr->init(10000, "Bonn, Hauptstraße 123"); Vdevice[0].init(20000, "Augsburg, Fuggerweg 345"); Vdevice[1].set_geld(25000); Vdevice[1].set_standort("Berlin, Berliner Allee 567"); device.init(123456, "Frankfurt, Goethestraße 123"); // Ausgabe cout << device_ptr->get_geld() << endl; cout << device_ptr->get_standort() << endl; for (size_t i = 0; i < Vdevice.size(); i++) { cout << Vdevice[i].get_geld() << endl; cout << Vdevice[i].get_standort() << endl; } cout << device.get_geld() << endl; cout << device.get_standort() << endl; counter++; } return 0; }
Automat Automat::diffGeld(const Automat& a1) { if( get_geld() > a1.get_geld() ) { return *this; } else { return a1; } }
Automat diffGeld(const Automat& a1, const Automat& a2) { if( a1.get_geld() > a2.get_geld() ) { return a1; } else { return a2; } }