01 // Explizite Funktionsanforderung - 2
02 // Datei: expliz2.cpp
03
04 #include <iostream.h>
05
06 template <class TYP>
07 TYP max (TYP op1, TYP op2)
08 {
09 return op1 > op2 ? op1 : op2;
10 }
11
12 int max (int, int);   // Explizite Deklaration
13
14 int main ()
15 {
16 int x;
17 x = max(10,20);
18 cout << "\n\nErgebnis: " << x;
19 x = max (‘A’,’B’);
20 cout << "\nErgebnis: " << hex << x;
21 x = max (20,’A’);          // nun klappt es
22 cout << "\nErgebnis: " << hex << x;
23
24 return 0;
25 }
26

Bild 17-8  Erzwungene Generierung einer Funktion