Created
February 17, 2017 06:47
-
-
Save jryebread/9bbfa819dd729e59973134b9d6b66f98 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
template <typename T> // this is the template parameter declaration | |
T max(T x, T y) | |
{ | |
return (x > y) ? x : y; | |
} | |
int main() | |
{ | |
double x, y; | |
x = 10.34234; | |
y = 324.324; | |
std::cout << max(x, y) << std::endl; | |
int x2,y2; | |
x2 = 4; | |
y2 = 5; | |
std::cout << max(x2, y2) << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment