Breymann. C++ Einführung und professionelle Programmierung

Breymann. C++ Einführung und professionelle Programmierung Breymann. C++ Einführung und professionelle Programmierung

vred.bioinf.uni.sb.de
von vred.bioinf.uni.sb.de Mehr von diesem Publisher
17.11.2014 Aufrufe

* Operator für den Fall v1 = zahl*v2; template mathVektor operator*(T zahl, const mathVektor &v) { mathVektor temp = v; return temp *= zahl; // Aufruf von operator*=() } // * Operator für den Fall v1 = v2*zahl; // (vertauschte Reihenfolge der Argumente) template mathVektor operator*(const mathVektor &v, T zahl) { mathVektor temp = v; return temp *= zahl; // Aufruf von operator*=() } Die Länge eines Vektors kann sich durch Zuweisung ändern: v1 = 1.234567 * v2; (9.3 Zuweisungsoperator und Vererbung wird übersprungen) Breymann C++, c○ Hanser Verlag München Inhalt ◭◭ ◭ ◮ ◮◮ 396 zurück Ende

9.4 Inkrement-Operator ++ Präfix- oder Postfix-Form. Beispiel: Datum-Klasse class Datum { public: Datum(); Datum(int t, int m, int j); void setzeDatum(int t, int m, int j); void aktuell(); // Systemdatum setzen bool Schaltjahr() const; Datum& operator++(); // Tag hochzählen, präfix const Datum operator++(int);// .... und postfix int Tag() const; // lesende Methoden int Monat() const; int Jahr() const; private: int tag, monat, jahr; }; Breymann C++, c○ Hanser Verlag München Inhalt ◭◭ ◭ ◮ ◮◮ 397 zurück Ende

9.4 Inkrement-Operator ++<br />

Präfix- oder Postfix-Form. Beispiel: Datum-Klasse<br />

class Datum {<br />

public:<br />

Datum();<br />

Datum(int t, int m, int j);<br />

void setzeDatum(int t, int m, int j);<br />

void aktuell();<br />

// Systemdatum setzen<br />

bool Schaltjahr() const;<br />

Datum& operator++(); // Tag hochzählen, präfix<br />

const Datum operator++(int);// .... <strong>und</strong> postfix<br />

int Tag() const; // lesende Methoden<br />

int Monat() const;<br />

int Jahr() const;<br />

private:<br />

int tag, monat, jahr;<br />

};<br />

<strong>Breymann</strong> <strong>C++</strong>, c○ Hanser Verlag München<br />

Inhalt ◭◭ ◭ ◮ ◮◮ 397 zurück Ende

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!