Converting From template base class nested class to template derived class nest class

  c++

Sorry from confusing title.

I am making a Red-Black Tree, that inherits from a Binary Search Tree.

The Binary Search Tree has a nested class, called Node, which has exactly what you’d expect.

Now for the RB Tree, obviously I need to store the nodes colour, so therefore I inherit from BST::Node, another Node Class which adds the colour.

Now the problem I am having is that it cannot convert a BST::Node to a RBT::Node.
This is how the code is setup:

BinarySearchTree.h

template<typename T>
class BinarySearchTree
{
public:
  struct Node
  {

        T m_Value;

        
        Node* m_pLower;

        
        Node* m_pHigher;

        
        Node* m_pParent;



  };
};

RedBlackTree.h

template<typename T>
class RedBlackTree : public BinarySearchTree<T>
{
public:
  struct Node : public BinarySearchTree<T>::Node
  {
      bool m_bColour;
  };
};

So when I am doing something in the RBT, such as repairing the tree or whatever, using a
RBT::Node, I get an error saying:
‘=’: cannot convert from ‘BinarySearchTree<int>::Node *’ to ‘RedBlackTree<int>::Node *’
.

For Example:

Node* pParent = pNode->m_pParent;

Thanks in advance.

Source: Windows Questions C++

LEAVE A COMMENT