随笔分类 -  template

模板_静态函数_初始化
摘要:#include #include using namespace std;templateclass S{public: S() {} static T* t; static void gen() { static T p; t = &p;/* t = new T();*/ }};class A : public S { public: char carr[1024]; };A* A::t = NULL;class B : public S { public: char carr[2048]; };B* B::t = N... 阅读全文

posted @ 2013-08-19 07:06 shizuka 阅读(300) 评论(0) 推荐(0)

used to template _step_1
摘要:#include <iostream>using namespace std;class elem{public: elem(int n) { i = n; } int i;};template<class T1>class ob{public: ob() {} virtual void foo1(T1* tData) { cout<<"foo1's out"<<endl; }};template<class T2>class obEx : public ob<T2>{public: T2 e; 阅读全文

posted @ 2012-07-24 22:25 shizuka 阅读(149) 评论(0) 推荐(0)

my_pair
摘要:eggache了一下.为了防止自己脑袋秀逗了,试了一下这个。大概这个意思,不过重载运算符没弄,用到字符串类型会有问题。#include <iostream>#include <string>using namespace std;namespace Y4{ template <typename T1, typename T2> class pair { public: T1 first; T2 second; pair() {;} pair(T1 val1, T2 val2) { ... 阅读全文

posted @ 2012-02-10 10:08 shizuka 阅读(195) 评论(0) 推荐(0)

导航