Pregunta

Say, I have a parent class template. And want to build several child class upon it. Each child class are typename specific. So can I specify the typename they use when inherit their parent class template?

example of the class definition:

 template <class tName1, class tName2>
 class parent
 {
     tName1 a;
     tName2 b;
     ...
 }

 class child: public parent<int, float>
 {
     ...
 }

Is this code correct?

¿Fue útil?

Solución

Yes, I can do it. It seems like each time I call a template in C++, I have to specify its type or make it into another template. In this case it's specifying its type.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top