STL源码剖析:class template partial specialization

/*
	class template partial specialization
*/
#include <iostream>

using namespace std;

// 一般化设计
template <class I, class O>
class testClass
{
public:
	testClass()
	{
		cout<<"I,O"<<endl;
	}
};

// 特殊化设计
template <class T>
class testClass<T*, T*>
{
public:
	testClass()
	{
		cout<<"T*,T*"<<endl;
	}
};

// 特殊化设计
template <class T>
class testClass<const T*, T*>
{
public:
	testClass()
	{
		cout<<"const T*, T*"<<endl;
	}
};

int main()
{
	testClass<int, char> obj1;
	testClass<int*, int*> obj2;
	testClass<const int*, int*> obj3;

	system("pause");
	return 0;
}

你可能感兴趣的:(STL源码剖析:class template partial specialization)