Skip to content

Instantly share code, notes, and snippets.

@congdanhqx-zz
Last active December 22, 2015 14:09
Show Gist options
  • Save congdanhqx-zz/6483949 to your computer and use it in GitHub Desktop.
Save congdanhqx-zz/6483949 to your computer and use it in GitHub Desktop.
Example for C++ Template.
#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