小弟弟 我 以前用的是 DELPHI, 最近转到VC 下。 学一点 WTL。
  我在 系统的模版类的上面 看到
    template <class T, class TBase >
  这么一句。
  不知道 里面 的 class T ,class TBase 分别表示什么。
  请高手指教。

解决方案 »

  1.   

    是不是指 下面 实例 这个类的时候 必须 要 继承 2 个 类。
      希望 举个例子 说明,小弟 不盛 感谢。  系统里的 代码是这样的:
    #define _ATL_RT_DLGINIT  MAKEINTRESOURCE(240)template <class TBase /* = CWindow */>
    class ATL_NO_VTABLE CDialogImplBaseT : public CWindowImplRoot< TBase >
    {
    public:
    virtual ~CDialogImplBaseT()
    {
    }
    virtual DLGPROC GetDialogProc()
    {
    return DialogProc;
    }
    static INT_PTR CALLBACK StartDialogProc(HWND hWnd, UINT uMsg,
    WPARAM wParam, LPARAM lParam);
    static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    BOOL MapDialogRect(LPRECT lpRect)
    {
    ATLASSERT(::IsWindow(m_hWnd));
    return ::MapDialogRect(m_hWnd, lpRect);
    }
    virtual void OnFinalMessage(HWND /*hWnd*/)
    {
    // override to do something, if needed
    }
    // has no meaning for a dialog, but needed for handlers that use it
    LRESULT DefWindowProc()
    {
    return 0;
    }
    // initialize combobox and comboboxex from RT_DLGINIT resource if any
    BOOL ExecuteDlgInit(int iDlgID)
    {
    return bSuccess;
    }
    };
      

  2.   

    struct Data
    {
      int x;
      int y;
    }
    CArray <Data,Data> m_dataArray;
    //定义Data的数组,第一个是希望放入数组的数据类型,第二个新加元素时要传入CArray类的对象,之后就可以如下访问:m_dataArray[i].x
      

  3.   

    里面的class T的class不是类。只是两种类型
    比如,这是书上的例子。:
    #include <iostream.h>
    // 定义类模板ABC
    template <class T, int I> class ABC //这里的T是不确定的数据类形
    { private:
          T array [I] ;       // 定义T类型的数组array
       public: 
          void  set (int x); // 定义成员函数set
          void  get () ; //定义成员函数get
     };
    template <class T,int I> void  ABC<T,I> ::set (int x) // 定义成员函数set,这是类模板的用法。
    {  int  i;
    for (i=0; i<I; i++) //循环I次
        {  array[i]=x+i; }                //数组元素赋值
    }
    template <class T,int I> void ABC<T,I>::get()

    cout <<"\n   数组元素总数为:"<< I<<endl;
    cout <<"   array["<<I-1<<"]="<<array[I-1]<<endl; 
    }
    void main()
    {  //由模板ABC生成对象abc1
        ABC <int,50> abc1;
        abc1.set(0);          //调用对象abc1.set
        abc1.get();           //调用对象abc1.get
    //由模板ABC生成对象abc2
      ABC <int,100> abc2;
      abc2.set(10);         //调用对象abc2.set
      abc2.get();             //调用对象abc2.get
    }
      

  4.   

    这么一说,对 STL 的泛型编程突然有了点感悟。
      果然 是 好东东。
      一定要好好研究研究。