Skip to content

Instantly share code, notes, and snippets.

@Mulperi
Created March 25, 2019 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mulperi/d2746f429b5de84b4a9f02884e9aae06 to your computer and use it in GitHub Desktop.
Save Mulperi/d2746f429b5de84b4a9f02884e9aae06 to your computer and use it in GitHub Desktop.
c++ template function
#include <iostream>
#include <string>
template <class T>
T getMax(T a, T b)
{
return a > b ? a : b;
}
int main()
{
std::cout << getMax(1, 2) << std::endl;
std::cout << getMax(2.1, 2.0) << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment