|
C++/Template Function1/0
Template Function

Templates let you write generic code that works with any type in C++. Write max<T> with template<typename T>: take two parameters of the same type and return the larger one using the > operator with a ternary.

C++ ยท medium
Start typing...
1template <typename T>
2T max(T a, T b) {
3 return (a > b) ? a : b;
4}