const als Rückgabewert
-
Hallo,
ich habe ein Verständnis Problem mit einer Funktion die const als Rückgabewert erwartet.
Ich nehme mal ein Beispiel von Scott Meyers Lektion 21:
const Rational operator*(const Rational&lhs, const Rational& rhs);
Er schreibt es ist nötig um scheußliche Dinge möglich wären wie:
Rational a,b,c; ... (a*b)=c; // Zuweisung an ein Produkt!
Mir ist klar das ich sowas nicht will, aber wie mach ich das nur mit dem const vorne dran?
Desweiteren, wenn ich einen const Rückgabewert habe, brauche ich dann auch eine const Instanz?Wäre für Hilfe dankbar!