c++/max.cpp
author Markus Bröker <mbroeker@largo.dyndns.tv>
Wed, 02 May 2012 20:51:14 +0200
changeset 165 f551b78c3eee
permissions -rw-r--r--
a bluetooth and a c++ demo committer: Markus Bröker <mbroeker@largo.homelinux.org>

#include <iostream>
#include <exception>

using namespace std;

template<class T>
void maxx(T a, T b) {
    if (a > b)
        cout << b << endl;
    else
        cout << a << endl;
}

void maxx(int a, int b) {
    cout << "handle ints special..." << endl;
}

int main(int argc, char **argv)
{
    double d1=3.2, d2=5.2;

    try {
        maxx(3.5, 5.1);
        maxx(5, 1);
        maxx(d1, d2);
    } catch (exception &e) {
        cout << e.what();
    }

    return 0;
}