template

作者: solk1234 | 来源:发表于2019-07-11 23:13 被阅读0次

    template

    function template.

    normal function template.

    template<class T>
    void pri(T a){}
    

    template specicalization.

    template<>
    void pri<bool>(){}
    

    class template.

    normal class template.

    template<class T>
    class A{void p(T v){}};
    

    full template specialization.

    template<>
    class A{void xx(){}};
    

    partial template specialization.

    template<>
    void A::p<int>(){}
    

    note1:the function p must exists.
    note2:The <type> is optional if compiler can conclude which function to call on the basis of par type when invoke function p,otherwise it's necceseery.

    相关文章

      网友评论

          本文标题:template

          本文链接:https://www.haomeiwen.com/subject/crtskctx.html