author | Markus Bröker<broeker.markus@googlemail.com> |
Sun, 22 Oct 2017 22:55:27 +0200 | |
changeset 172 | 43ae72f88d06 |
parent 165 | f551b78c3eee |
permissions | -rw-r--r-- |
165
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
1 |
#include <iostream> |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
2 |
#include <exception> |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
3 |
|
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
4 |
using namespace std; |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
5 |
|
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
6 |
template<class T> |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
7 |
void maxx(T a, T b) { |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
8 |
if (a > b) |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
9 |
cout << b << endl; |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
10 |
else |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
11 |
cout << a << endl; |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
12 |
} |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
13 |
|
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
14 |
void maxx(int a, int b) { |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
cout << "handle ints special..." << endl; |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
16 |
} |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
17 |
|
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
18 |
int main(int argc, char **argv) |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
19 |
{ |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
20 |
double d1=3.2, d2=5.2; |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
21 |
|
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
try { |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
maxx(3.5, 5.1); |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
24 |
maxx(5, 1); |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
25 |
maxx(d1, d2); |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
26 |
} catch (exception &e) { |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
27 |
cout << e.what(); |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
28 |
} |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
29 |
|
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
30 |
return 0; |
f551b78c3eee
a bluetooth and a c++ demo
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
31 |
} |