Last active
December 22, 2015 14:09
-
-
Save congdanhqx-zz/6483949 to your computer and use it in GitHub Desktop.
Example for C++ Template.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
template <class T> | |
T GetMax (T a, T b) { | |
T result; | |
result = (a > b) ? a : b; | |
return result; | |
} | |
int main () { | |
int i = 5, j = 6, k; | |
long l = 10, m = 5, n; | |
k = GetMax<int>(i, j); | |
n = GetMax<long>(l, m); | |
cout << k << endl; | |
cout << n << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment