일상 코딩
[C++/CPP] 13.01.함수 template 본문
728x90
C++ 온라인 컴파일러 사이트
- https://replit.com/~
- https://www.onlinegdb.com/online_c++_compiler
- https://cpp.sh/
- https://www.tutorialspoint.com/compile_cpp_online.php
#include<iostream>
using namespace std;
template<typename T>
T getMax(T x, T y)
{
return (x > y) ? x : y;
}
int main()
{
{
cout << getMax(1, 2) << endl;
cout << getMax(3.14, 1.592) << endl;
cout << getMax(1.0f, 3.4f) << endl;
cout << getMax('a', 'c') << endl;
}
return 0;
}
728x90