I implemented a RedBlackTree from scratch and now I want to implement an ordered map from scratch using that RBT.
I have a class RBT and inside of it a struct called TreeNode.
I have a separate class Map and inside of it a class called Iterator.
The problem is that when I try to declare a TreeNode pointer inside my Iterator it won’t recognize it
class Iterator
{
RBT<KeyType, ValueType, Compare>::TreeNode* node;
Map& map;
public:
Iterator(RBT<KeyType, ValueType, Compare>::TreeNode* nodePointer, Map& mapReference)
: node(nodePointer), map(mapReference) {}
...
}
I tried to do forward declarations,to make the class Map and class Iterator friends of the class RBT but it still won’t work.
Mario is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1