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

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

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

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

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!