#include <iostream>
using namespace std;
// 템플릿
template <typename T1, typename T2>
class MySimple
{
public:
void WhoAreYou()
{
cout << "size of T1: " << sizeof(T1) << endl;
cout << "size of T2: " << sizeof(T2) << endl;
cout << "<typename T1, typenmae T2>" << endl;
}
};
// 템플릿 특수화
template<>
class MySimple<int, double>
{
public:
void WhoAreYou()
{
cout << "size of int: " << sizeof(int) << endl;
cout << "size of double: " << sizeof(double) << endl;
cout << "<typename int, typenmae double>" << endl;
}
};
// 템플릿 부분특수화
template<typename T1>
class MySimple<T1, double>
{
public:
void WhoAreYou()
{
cout << "size of T1: " << sizeof(T1) << endl;
cout << "size of double: " << sizeof(double) << endl;
cout << "<typename T1, typenmae double>" << endl;
}
};
int main(void)
{
// 부분특수화
MySimple<char, double> obj1; obj1.WhoAreYou();
// 템플릿
MySimple<int, long> obj2; obj2.WhoAreYou();
// 템플릿 특수화
MySimple<int, double> obj3; obj3.WhoAreYou();
return 0;
}