250x250
Notice
Recent Posts
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
관리 메뉴

일상 코딩

[C++/CPP] 13.01.함수 template 본문

C++/따배C++ 13강 템플릿

[C++/CPP] 13.01.함수 template

polarcompass 2022. 1. 5. 19:49
728x90
C++ 온라인 컴파일러 사이트
  1. https://replit.com/~
  2. https://www.onlinegdb.com/online_c++_compiler
  3. https://cpp.sh/
  4. 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