template <class T>
class IntermittentQueue : Queue<T> { /* some other statements */ };
This defines a new template class:
template <class T>
class IntermittentQueue { }
that at the same time inherits from another one, such as:
class Base { };
class Derived : Base { };
Solely, that in this case, the base class is an instantiation of another template class:
template <typename T>
class Base { };
class Derived : Base<int> { };
using the derived class' template parameter as template argument (and now we are back at the original code again...).
template <class T>
typename IntermittentQueue<T>::Node* IntermittentQueue<T>::getNode(const node_ptr nodePtr)
{ /* some other statements */ };
This is the implementation of one of the member functions of a template class. Step by step:
template <class T> // the class we are speaking off is a template class
typename IntermittentQueue<T>::Node* // return value of the function
IntermittentQueue<T>::getNode // function name with (template) class scope specified
// (just as with SomeClass::someMemberFunction)
(const node_ptr nodePtr) // function parameter(list)
{ /* some other statements */ }; // function body
Fine so far, but the return type might need further explanation:
typename IntermittentQueue<T>::Node*
The function returns a pointer to an object of inner class type Node
of (template) class IntermittentQueue
:
IntermittentQueue<T>::Node*
As inner type is a dependent type, you need to explicitly tell the compiler that this actually is a type at all, this is what the typename
keyword then is used for; for details: there's already another question to the topic.
Just a side note here: Having typedefs for pointers (node_ptr
) is bad practice, that's just information hiding and does not serve anything valuable for (the exception from: the pointer serves as a handle to some internal resource and is not intended to be dereferenced anywhere outside – then explicitly hiding the pointer nature is valid).