I'm trying to make a Binary Search Tree class that inherits from a Tree class but the compiler says that the data members of the Tree class aren't inherited in the BST class.
Tree.h
template <class T>
class Tree {
protected:
class Node {
public:
T value;
Node * left;
Node * right;
};
Node * root;
public:
Tree() : root(NULL) { }
};
BST.h
template <class T>
class SearchTree : public Tree<T> {
public:
void foo();
};
template <class T>
void SearchTree<T>::foo() {
Node * node = NULL; //error- Unknown type name 'Node'
root = node; //error- Use of undeclared identifier 'root'
}
I expect to be able to access Node and root from the base class "Tree". Why is the compiler saying they are undeclared and unknown?