c++ - why Specialized template class need forward declaration? -
such code:
template<typename,int> class uoo; //without result in complie error,why? template<typename t> class uoo<t,1> { }; int main(){ return 0; }
why specialized template class need forward declaration?
the following code specialisation of template.
template<typename t> class uoo<t,1> { };
but haven't said unspecialised form is, , language requires that. need add prototype:
template<typename,int> class uoo;
you don't need declare unspecialised form since instance of never required. prototype sufficient.
Comments
Post a Comment