I have this college project where I have to create a BinarySearchTree class using templates. We have to read a file and create the tree depending of the data type in the file. I made a parent class for the tree called BST so I can use the tree without giving it a class type.
class BST{
public:
BST();
~BST();
}
And the tree
template <class T> class BinarySearchTree : public BST{
public:
void add(T val);
}
And I wanted to do this:
BST tree = BinarySearchTree<int>(); //just an example, it can be of any type
tree.add(5); //doesn't work
How can I call "add" from BST without giving a specific variable type?