equal
deleted
inserted
replaced
|
1 #include <iostream> |
|
2 #include <cstdlib> |
|
3 |
|
4 template<class T> |
|
5 T add(T a, T b) |
|
6 { |
|
7 return a+b; |
|
8 } |
|
9 |
|
10 int add (int a, int b) |
|
11 { |
|
12 std::cout << "overloaded..." << std::endl; |
|
13 return b+a; |
|
14 } |
|
15 |
|
16 int main(int argc, char **argv) |
|
17 { |
|
18 float a, b; |
|
19 int c, d; |
|
20 std::string s1, s2; |
|
21 |
|
22 a = 1.0; |
|
23 b = 2.5; |
|
24 |
|
25 c = 1; |
|
26 d = 2; |
|
27 |
|
28 s1 = "Hello "; |
|
29 s2 = "World!"; |
|
30 |
|
31 std::cout << add (a, b) << std::endl; |
|
32 std::cout << add (c, d) << std::endl; |
|
33 std::cout << add (s1, s2) << std::endl; |
|
34 |
|
35 return EXIT_SUCCESS; |
|
36 } |