Please explain the difference between the two following template definition:
1 2 3 4 5 6 7 8 9 10
template <typename E> // base element type
class Position<E> { // a node position
public:
E& operator*(); // get element
Position parent() const; // get parent
PositionList children() const; // get node's children
bool isRoot() const; // root node?
bool isExternal() const; // external node?
};
and
1 2 3 4 5 6 7 8 9 10 11
template <typename E> // base element type
class Position { // a node position
public:
E& operator*(); // get element
Position parent() const; // get parent
PositionList children() const; // get node's children
bool isRoot() const; // root node?
bool isExternal() const; // external node?
};
I cannot understand the <E> part after the class Position. Some explanation would be helpful.
The first code snippet is of a so-called template specialization. Like the name implies, you would use template specialization when having a different or unique implementation for a specific type would make more sense.