<span style="font-size:24px;">#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
template <typename T>
class Test
{
private:
public:
T test(T v)
{
cout << "sizeof(T) = " << sizeof(T) << endl;
return v;
}
protected:
};
//类模版的特化
template <>
class Test<int>
{
private:
public:
int test(int v)
{
cout << "sizeof(int) = " << sizeof(int) << endl;
return v;
}
protected:
};
//类模版的特化 的 共有继承
class MyTest : public Test<int>
{
private:
public:
protected:
};
int main()
{
Test<int> a;
cout << a.test(1) << endl;
MyTest aa;
cout << aa.test(10) << endl;
Test<float> b;
cout << b.test(1.2) << endl;
return 0;
}</span>