Skip to content

Instantly share code, notes, and snippets.

@jryebread
Created February 17, 2017 06:47
Show Gist options
  • Save jryebread/9bbfa819dd729e59973134b9d6b66f98 to your computer and use it in GitHub Desktop.
Save jryebread/9bbfa819dd729e59973134b9d6b66f98 to your computer and use it in GitHub Desktop.
#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