More actions
imported>장용운 No edit summary |
(Repair batch-0007 pages from live compare) |
||
| Line 35: | Line 35: | ||
템플릿 함수를 선언할 때, 선언부와 정의부를 분리하면 에러가 나는데 왜 그런지 모르겠다. | 템플릿 함수를 선언할 때, 선언부와 정의부를 분리하면 에러가 나는데 왜 그런지 모르겠다. | ||
Latest revision as of 01:32, 27 March 2026
개요
복습 차원에서 템플릿을 공부하고 연습하였다.
소스
#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
후기
템플릿 함수를 선언할 때, 선언부와 정의부를 분리하면 에러가 나는데 왜 그런지 모르겠다.