Is the following permissible when using templates.
template <typename PAR1 = X,
typename PAR2 = Y,
typename PAR3 = Z>
class Base {
//some stuff inside
};
template <typename PAR1
typename PAR2 = Z>
class Derived : public Base <PAR1,Y,PAR2> {
//some stuff here
};
what i want here is that Derived class should always have the PAR2 type as Y.
Can we fix the parameter value when others parameters after it as optional while inheriting ?
I guess you are confused by template default value and partial specialization. Because Base takes 3 parameters with default value, you could instantiate Base with from 0 to 3 parameters.
In Derived class, you are inheriting from situation
#4which is of course valid.So you can inherit from any form of Base above.
Base template parameter can be independent type(value) or passed from
template <typename PAR1, typename PAR2 = Y>OR
OR