Code:
#include <iostream>
using namespace std;
class KONTO
{
private:
int KONTOSTAND;
public:
int WERT_AENDERUNG(int);
int KONTOSTAND_LESEN();
};
int KONTO::WERT_AENDERUNG(int EINGABE) {
if ((EINGABE>=0)&&(EINGABE<=100000)) {
KONTOSTAND=EINGABE;
return(1);
}
return(0);
}
int KONTO::KONTOSTAND_LESEN()
{
return (KONTOSTAND);
}
int main()
{
KONTO TESTKONTO;
TESTKONTO.WERT_AENDERUNG(0);
int ALTERNATIVE, WERT=0;
cout << "K O N T O V E R W A L T U N G" << endl;
do {
cout << "1 = KONTOSTAND AENDERN" << endl;
cout << "2 = KONTOSTAND LESEN" << endl;
cout << "0 = Ender der Akton" << endl << endl;
cout << "Ihre Wahl: ";
cin >> ALTERNATIVE;
switch (ALTERNATIVE) {
case 1: cout << "Neuer WERT: ";
cin >> WERT;
if (TESTKONTO.WERT_AENDERUNG(WERT))
cout << "WERT geaendert." << endl << endl;
break;
case 2: cout << "Aktueller WERT: ";
cout << TESTKONTO.KONTOSTAND_LESEN() << endl << endl;
break;
}
} while (ALTERNATIVE != 0);
system("pause");
return 0;
}
Es geht um die Methode WERT_AENDERUNG(int), return gibt ja einen Wert an die Funktion WERT_AENDERUNG(int) zurück. Was bedeutet diese 1 oder die 0 nach return? Und warum die runden Klammern, in der main is ja bei return 0 auf keine Klammer um die 0.
2. Frage: Was genau ist ein Kontruktor, Destruktor? Also jetzt nicht irgendwo copy&paste sondern mit eigenen Worten erklärt.