C++Template学习

template<typename T>
void funcTmp(T a, T b)
{
    cout << "this is yiban" << endl;
}


template<>
void funcTmp(const char* a, const char* b)
{
    cout << "this is char*" << endl;
}


template<typename T>
class CTem 
{
public:
    void func()
    {
        cout << "this is usural func" << endl;

    }
};

void CTem<char>::func()
{
    cout << "this is char func" << endl;
}

template<>
class CTem<int>
{
public:
    void func()
    {
        cout << "this is int func" << endl;

    }
};

 

posted @ 2021-03-30 19:27  唯一诺  阅读(50)  评论(0编辑  收藏  举报