#include <iostream>
template<typename T, int size = 10>
class c
{
T m[size];
public:
void print_size()
{
std::cout << size << std::endl;
}
};
template<> class c<int>
{
char m[100];
public:
void print_size()
{
std::cout << 100 << std::endl;
}
};
int main()
{
c<int>().print_size();
c<int,10>().print_size();
c<int,11>().print_size();
system("pause");
return 0;
}
结果为:
100
100
11
特化这类模板的时候需要注意一下.