1 // Kopier- Konstruktor
2 // Datei: ratkop.cpp
3 #include "ratkop.hpp"
4
5 ratio::ratio (int zae, int ne)
6 {
7 z = zae, n = ne;
8 }
9 ratio::ratio
(const ratio & robjekt)
10 {
11 printf ("\nHier ist der Kopierkonstruktor.");
12 z = robjekt.z;
13 n = robjekt.n;
14 }
15 // Nur ausgeben, was unbedingt
zu ratio gehört
16 void ratio::print ()
17 {
18 printf ("%d/%d",z, n);
19 }
20
21 ratio ratio::addiere (ratio op2)
22 {
23 ratio erg;
24 erg.z
= z * op2.n + n * op2.z;
25 erg.n = n * op2.n;
26 return erg;
27 }
|
Bild 6-13: Implementierung des Kopierkonstruktors
|