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.
网友评论