Breymann. C++ Einführung und professionelle Programmierung
Breymann. C++ Einführung und professionelle Programmierung Breymann. C++ Einführung und professionelle Programmierung
Aktualisierung der Klasse Ort: #ifndef ort_h #define ort_h ort_h #include #include using namespace std; // wegen sqrt() class Ort { public: Ort(int einX = 0, int einY = 0) : xKoordinate(einX), yKoordinate(einY) { } int X() const { return xKoordinate;} int Y() const { return yKoordinate;} void aendern(int x, int y) { xKoordinate = x; yKoordinate = y; } Breymann C++, c○ Hanser Verlag München Inhalt ◭◭ ◭ ◮ ◮◮ 162 zurück Ende
}; private: int xKoordinate, yKoordinate; // globale Funktion zur Berechnung der // Entfernung zwischen zwei Orten inline double Entfernung(const Ort &Ort1, const Ort &Ort2) { double dx = static_cast(Ort1.X() - Ort2.X()); double dy = static_cast(Ort1.Y() - Ort2.Y()); return sqrt(dx*dx + dy*dy); } inline void anzeigen(const Ort &O) { cout
- Seite 111 und 112: 4.3 Grundsätze der modularen Gesta
- Seite 113 und 114: 4.3.2 Einbinden vorübersetzter Pro
- Seite 115 und 116: mainprog.cpp #include "a.h" #includ
- Seite 117 und 118: Üblich: make-Files oder „Projekt
- Seite 119 und 120: Beschränkung des Gültigkeitsberei
- Seite 121 und 122: 4.3.4 Übersetzungseinheit, Deklara
- Seite 123 und 124: one definition rule Jede Variable,
- Seite 125 und 126: Inhalt von Implementations-Dateien
- Seite 127 und 128: 4.3.5 Compilerdirektiven sind Anwei
- Seite 129 und 130: Makros mit #define zum Ersetzen von
- Seite 131 und 132: Eine weitere übliche Anwendung von
- Seite 133 und 134: Nur mit den Sprachelementen von C++
- Seite 135 und 136: Verifizieren logischer Annahmen mit
- Seite 137 und 138: template int kleiner(const T& a, co
- Seite 139 und 140: * Erst in der folgenden Anweisung w
- Seite 141 und 142: 4.5 inline-Funktionen inline ist ei
- Seite 143 und 144: 5. Objektorientierung 1 - Abstrakte
- Seite 145 und 146: } // ... Protokollierung Punkt einP
- Seite 147 und 148: Eigenschaften: • Der Sinn liegt d
- Seite 149 und 150: class Klassenname { public: Typ Ele
- Seite 151 und 152: Anwendung: // ort1main.cpp #include
- Seite 153 und 154: aendern() soll Änderungen der Koor
- Seite 155 und 156: 2. Deklaration und Definition inner
- Seite 157 und 158: 5.3 Initialisierung und Konstruktor
- Seite 159 und 160: 5.3.2 Allgemeine Konstruktoren Allg
- Seite 161: Initialisierung mit Listen Beispiel
- Seite 165 und 166: 5.3.3 Kopierkonstruktor engl.: copy
- Seite 167 und 168: Übergabe von Objekten an eine Funk
- Seite 169 und 170: Zahl bilden int Koordinate = 0; whi
- Seite 171 und 172: Verhindern impliziter Typwandlungen
- Seite 173 und 174: Folgende Funktionen sollen von der
- Seite 175 und 176: Beschränkungen und Hinweise - Kür
- Seite 177 und 178: Möglichkeiten für Operationen mit
- Seite 179 und 180: void eingabe(); void ausgabe() cons
- Seite 181 und 182: 5.4.3 Implementation void rational:
- Seite 183 und 184: void rational::sub(const rational&
- Seite 185 und 186: long ggt(long x, long y) { // wird
- Seite 187 und 188: ational mult(const rational& a, con
- Seite 189 und 190: 5.6 Faustregeln zur Konstruktion vo
- Seite 191 und 192: Regeln: 1. Die geplante Anwendung b
- Seite 193 und 194: 5. Die Art der Übergabe eines Obje
- Seite 195 und 196: (a) Diese Anweisung wird von links
- Seite 197 und 198: Natürlich kann von den Empfehlunge
- Seite 199 und 200: class Beispiel { int zahl; public:
- Seite 201 und 202: 5.8 Wie kommt man zu Klassen und Ob
- Seite 203 und 204: 5.8.1 Einige Analyse-Überlegungen
- Seite 205 und 206: 6. Intermezzo: Zeiger - Zeiger und
- Seite 207 und 208: . 99 . . 10123 . Adresse Name 10122
- Seite 209 und 210: int *ip2 = &i; bewirkt: ip ip2 ❩
- Seite 211 und 212: NULL-Zeiger Eigenschaften: • Ein
Aktualisierung der Klasse Ort:<br />
#ifndef ort_h<br />
#define ort_h ort_h<br />
#include<br />
#include<br />
using namespace std;<br />
// wegen sqrt()<br />
class Ort {<br />
public:<br />
Ort(int einX = 0, int einY = 0)<br />
: xKoordinate(einX), yKoordinate(einY) {<br />
}<br />
int X() const { return xKoordinate;}<br />
int Y() const { return yKoordinate;}<br />
void aendern(int x, int y) {<br />
xKoordinate = x;<br />
yKoordinate = y;<br />
}<br />
<strong>Breymann</strong> <strong>C++</strong>, c○ Hanser Verlag München<br />
Inhalt ◭◭ ◭ ◮ ◮◮ 162 zurück Ende