home *** CD-ROM | disk | FTP | other *** search
- // list2.cpp: Implementierung der Klasse List
- // Aus Kapitel 6 der Einführung
-
- #include <iostream.h>
- #include "list2.h"
-
- int List::put_elem(int elem, int pos)
- {
- if (0 <= pos && pos < nmax)
- {
- list[pos] = elem;
- return 0;
- }
- else
- return -1; // Nicht-Null bedeutet Fehler
- }
-
- int List::get_elem(int& elem, int pos)
- {
- if (0 <= pos && pos < nmax)
- {
- elem = list[pos];
- return 0;
- }
- else
- return -1; // Nicht-Null bedeutet Fehler
- }
-
- void List::print()
- {
- for (int i = 0; i < nelem; ++i)
- cout << list[i] << "\n";
- }
-