菜鸟笔记
提升您的技术认知

c 类中模版成员函数-ag真人游戏

c 函数模版与类模版。

template 
void swapfunction(t &first, t &second){
}//函数模版

template //类模版

class ctemplate{

public:

    void swap(t &first, t &second){

    }

};

 

#include 
class single{
public:
    static single*  shareinstance();
    static void releaseinstance();
     template//要成员函数实现模版用法,而类不是模版类。需要写成这个格式
    void swapex(tex &obj1, tex &obj2){
    }
private:
    single();
    ~single();
    single(const single &other);
    single& operator=(const single &other);
    
private:
    static single *m_pobj;
};
single* single::m_pobj = null;
single* single::shareinstance(){
    if (null == m_pobj) {
        single obj;
        m_pobj = new single();
    }
    return m_pobj;
}
void single::releaseinstance(){
    if (m_pobj) {
        delete m_pobj;
        m_pobj = null;
    }
}
single::single(){
    
}
single::~single(){
    
}

 

网站地图