개요 ¶
복습 차원에서 템플릿을 공부하고 연습하였다.
소스 ¶
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
template <typename T>
T multiply(T a, T b) {
return a*b;
}
template <typename U>
U subtract(U a, U b) {
return a-b;
}
int main(void) {
cout<<multiply(4,5)<<endl;
cout<<multiply(subtract(5,3),subtract(3,5))<<endl;
return 0;
}
Output ¶
20
-4
-4
후기 ¶
템플릿 함수를 선언할 때, 선언부와 정의부를 분리하면 에러가 나는데 왜 그런지 모르겠다.










