Breymann. C++ Einführung und professionelle Programmierung
Breymann. C++ Einführung und professionelle Programmierung Breymann. C++ Einführung und professionelle Programmierung
* 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
- Seite 346 und 347: 8.6.1 Namenskonflikte cout
- Seite 348 und 349: Subobjekt1: GraphObj Subobjekt2: Gr
- Seite 350 und 351: eschriftetesRechteck(const Ort &O,
- Seite 352 und 353: 8.6.3 Virtuelle Basisklassen und In
- Seite 354 und 355: class Unten: public Links, public R
- Seite 356 und 357: class Unten: public Links, public R
- Seite 358 und 359: class Rechteck { public: virtual vo
- Seite 360 und 361: Ohne Vererbung (Delegation): class
- Seite 362 und 363: 8.7.2 Der Teil und das Ganze „Tei
- Seite 364 und 365: } Bekanntenkreis.Hinzufuegen(&P); S
- Seite 366 und 367: 8.7.4 „Benutzt“-Beziehung Ein O
- Seite 368 und 369: ReturnDatentyp Klassenname::operato
- Seite 370 und 371: 1. Der Aufruf wird entsprechend der
- Seite 372 und 373: drei Fälle für gemischte Datentyp
- Seite 374 und 375: Ohne Typumwandlungskonstruktor Um g
- Seite 376 und 377: Mit Typumwandlungskonstruktor Wenn
- Seite 378 und 379: 9.1.2 Ausgabeoperator
- Seite 380 und 381: ✬ ✩ Vektor-Objekt start xDim (=
- Seite 382 und 383: Zuweisungsoperator Vektor& operator
- Seite 384 und 385: template inline void Vektor::init(c
- Seite 386 und 387: Zuweisung von Vektorelementen per W
- Seite 388 und 389: Möglicher Einsatz: Vektor v(5); //
- Seite 390 und 391: template inline Vektor &Vektor::ope
- Seite 392 und 393: 9.2.3 Mathematische Vektoren Vektor
- Seite 394 und 395: 9.2.4 Multiplikations-Operator Anwe
- Seite 398 und 399: Um bereits vor der Konstruktion ein
- Seite 400 und 401: void Datum::aktuell() { // Systemda
- Seite 402 und 403: Der Postfix-Inkrementierungsoperato
- Seite 404 und 405: datum.h #include class Datum { // .
- Seite 406 und 407: Es ist sowohl die implizite als auc
- Seite 408 und 409: 3. errno setzen 4. Fehlerbehandlung
- Seite 410 und 411: Wege zur Fehlerbehandlung: • Den
- Seite 412 und 413: gegebenenfalls weitere catch-Blöck
- Seite 414 und 415: 10.1.2 Exception-Hierarchie in C++
- Seite 416 und 417: Breymann C++, c○ Hanser Verlag M
- Seite 418 und 419: Große Teile des Konzepts sind durc
- Seite 420 und 421: 11.1 Die C++ Standardbibliothek, ge
- Seite 422 und 423: 11.1.1 Abstrakte und implizite Date
- Seite 424 und 425: 11.1.2 Bauelemente Container Klasse
- Seite 426 und 427: Allen Containern gemeinsam sind auc
- Seite 428 und 429: Iteratoren = Objekte, die auf Eleme
- Seite 430 und 431: Vorhandene Algorithmen: for_each fi
- Seite 432 und 433: } int Zahl = 0; do { cout > Zahl; I
- Seite 434 und 435: Variante 2: Prototyp durch Template
- Seite 436 und 437: } do { cout > Zahl; // Benutzung vo
- Seite 438 und 439: 11.2 Iteratoren im Detail Iteratore
- Seite 440 und 441: 11.2.1 Iteratorkategorien → sind
- Seite 442 und 443: • Random-Access-Iterator wie Bidi
- Seite 444 und 445: Ja. Schwachstelle: • Die Algorith
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