I am trying to implement Set based on binary tree search. Therefore, I create this collection starting with root (a pointer to Node), where Node matters, the right and left children (both pointers to Node). That way, I could install a new Node to the right of the Node root, specifying root-> the right to create the Node, and so on. Take a look at the definitions:
template <class T> class Set { public: Set(); ~Set(); void push(const T&); bool belongs(const T&) const; void remove(const T&); const T& min() const; const T& max() const; unsigned int cardinal() const; void show(std::ostream&) const; friend ostream& operator<<(ostream& os, const Set<T> &c) { c.show(os); return os; } private: struct Node { Node(const T& v); T value; Node* left; Node* right; }; Node* root_; int cardinal_; Node & fatherOfNode(const Node & root, const T & key, const bool hook) const; }; ...
So, I have this error:
/home/jscherman/ClionProjects/algo2-t3-bts/set.hpp:247:1: error: 'Node' does not name a type Node & Set<T>::fatherOfNode(const Node & root, const T & key, const bool hook) const { ^
I saw many posts related to this error, but most of them were caused by writing functions before the definitions. As you can see, the implementation of fatherOfNode is below its definition, so it doesn't seem to be my thing.
Any idea what is going on?
source share