1 // Beispiel 1:
  2 // Datei: ratiob1.hpp
  3 #include <stdio.h>
  4
  5 #ifndef RATIOHEADER
  6 #define RATIOHEADER
  7 class ratio
  8 {
  9 private:        // ist Voreinstellung
 10 int zae;        // Eigenschaften der Klasse
 11 int nen;        // zaehler und nenner
 12 public:         // Methoden/Konstruktor
 13       ratio (int zaehler = 0, int nenner = 1);
 14 void  print (); // Inhalt anzeigen
 15 ratio addiere (ratio *operand2);
 16 ratio subtrahiere (ratio *operand2);
 17 void  zuweisung (int zz, int nn);
 18 };
 19 #endif

Bild 4-14: Erweiterte Klassendefinition für "ratio"