To keep things simple, lets say I have a Node class, each node has a Node* to another (previous ) node in a list. I want to create a getter function that, when called upon a Node, returns the pointer to the previous node.
However when I’m defining this function I get the aforementioned error message: Expected constructor, destructor, or type conversion before '*' token
Would really appreciate and advice!
Here’s my Node class declaration:
template<typename NodeType>
class Node{
public:
...
Node* GetPrev();
private:
...
Node* _prev;
};
and implementation:
template <typename NodeType>
Node* Node<NodeType>::GetPrev()
{
return _prev;
}
Try
Node<NodeType>* Node<NodeType>::GetPrev().