Systemnahe Programmierung in C: Typen als Parameter |
1template <class Element>
2class StackInterface {
3
4public:
5
6 virtual void push(Element i) = 0;
7 virtual void pop() = 0;
8 virtual int top() = 0;
9 virtual int isEmpty() = 0;
10};
11
12template <class Element>
13class StackAsArry : public StackInterface<Element> {
14
15private:
16
17 Element a[20];
18 unsigned int topPtr;
19
20public:
21 void push(Element i) {
22 // ...
23 }
24
25 // ...
26};
27
28typedef StackAsArray<int> StackOfInts;
29typedef StackAsArray<double> StackOfReals;
|
|
Letzte Änderung: 11.01.2007 | © Prof. Dr. Uwe Schmidt |