c++/max.cpp
changeset 165 f551b78c3eee
equal deleted inserted replaced
164:e1f4bba1097a 165:f551b78c3eee
       
     1 #include <iostream>
       
     2 #include <exception>
       
     3 
       
     4 using namespace std;
       
     5 
       
     6 template<class T>
       
     7 void maxx(T a, T b) {
       
     8     if (a > b)
       
     9         cout << b << endl;
       
    10     else
       
    11         cout << a << endl;
       
    12 }
       
    13 
       
    14 void maxx(int a, int b) {
       
    15     cout << "handle ints special..." << endl;
       
    16 }
       
    17 
       
    18 int main(int argc, char **argv)
       
    19 {
       
    20     double d1=3.2, d2=5.2;
       
    21 
       
    22     try {
       
    23         maxx(3.5, 5.1);
       
    24         maxx(5, 1);
       
    25         maxx(d1, d2);
       
    26     } catch (exception &e) {
       
    27         cout << e.what();
       
    28     }
       
    29 
       
    30     return 0;
       
    31 }