c++ - Who partial specialization may inherit from a class template -
i trying make partial specialize class may inherit class template, compile gives error. code , error given below.
template<class t> class a{}; template<class t> class b<t*>:a<t>{}; main(){ a<int> obj1; b<int*> obj2; }
error:
error: 'b' not template error: expected class-name before '{' token
when replace b class code code
class b:public a<t>{};
it works.
in order partially specialize template, must have created primary template. if want define b<t*>
must first define b
.
that is, following error:
template<class t> class a{}; template<class t> class b<t*>:a<t>{};
this valid:
template<class t> class a{}; // primary template template<class t> class b{}; // partially specialized pointers template<class u> class b<u*>:a<u>{};
Comments
Post a Comment