I’m a little confused about how to properly declare a class inherited from a template class.
The base class looks like so (not including the irrelevant bits):
template <class Writer>
class Node
{
Writer* writer;
...
public:
Node (std::string& root);
...
}
What is the proper way to declare and construct an inherited class of this?
I thought something like:
template <class Writer>
class IndexNode : public Node
{...}
However, doing so is giving me “expected class-name before '{' token“. I’ve tried commenting out the template declaration in the inherited class, thinking that maybe the template declaration itself was inherited from the parent, but that did not help either, and also tried
class IndexNode : template <class Writer> public Node
{...}
, thinking maybe the template had to be explicitly attached to the base class. I figured rather than continue to take a stab at the right combination, I’d ask for assistance and hopefully learn something that will make me understand the reasons why also.
Thanks!
Is your derived class also a template?
Yes:
No: