제목 : 24.2. 함수 템플릿 : 템플릿_함수템플릿.cpp
글번호:
|
|
184
|
작성자:
|
|
레드플러스
|
작성일:
|
|
2005/08/23 오후 8:42:37
|
조회수:
|
|
3918
|
#include <iostream.h>
template<class T> void swap(T *a, T *b)
{
T t = *a;
*a = *b;
*b = t;
}
void main()
{
int i = 3, j =5;
cout << "i = " << i << ", j = " << j << endl;
swap(&i, &j);
cout << "i = " << i << ", j = " << j << endl;
char *s = "Hello", *t = "world";
cout << "s = " << s << ", t = " << t << endl;
swap(&s, &t);
cout << "s = " << s << ", t = " << t << endl;
}