求个通俗易懂的模板函数的例子

解决方案 »

  1.   

    http://blog.chinaunix.net/u1/45018/showart_353795.html
      

  2.   

    template<typename T>
    const T&  max(const T& t1, const T& t2)
    {
        return t1 < t2 ? t2 : t1; 
      

  3.   

    http://www.programfan.com/club/showpost.asp?id=126157&t=o
      

  4.   


         d3d::Release<IDirect3DTexture9*>(ShadeTex);
        d3d::Release<IDirect3DVertexShader9*>(ToonShader);
        d3d::Release<ID3DXConstantTable*>(ToonConstTable);要有这个样子的
      

  5.   


    const T&  max(const T& t1, const T& t2)
    {
        return t1 < t2 ? t2 : t1; 
    } 这个可以像下面这样应用int a = max<int>(3, 4);