类模板的特化,局部化以及缺省模板的实参

来源:互联网 发布:乐视2手机网络时间不准 编辑:程序博客网 时间:2024/06/16 10:32

// 泛型编程.cpp : 定义控制台应用程序的入口点。//

#include "stdafx.h"#include <iostream>using namespace std;

//类模板template <class T>class CC{public: void hh(T itemp){} void pp(T kk){}};//类模板的特化template<>class CC<std::string>{public: void hh(std::string pp){}};

//类模板template<typename t1, typename t2>class BB{public: BB() {  cout << "BB cons" << endl; } };//类模板的局部化template <typename T>class BB<T, T>{public: BB() {  cout << "local BB cons" << endl; }};//类模板的缺省实参template <class T, typename AINT = int>class AA{public: AA();};

AA<class T,  int>::AA(){

};

 

int _tmain(int argc, _TCHAR* argv[]){ BB<int, int> ibb; getchar(); return 0;}