So I am attempting to convert an int based binary search tree I created earlier into a templated binary search tree. I am struggling with how to type out my .cpp file.
In my .h file I have:
template <typename T>
class BST
{
private:        
    struct node
    {
        T m_data;
        node* m_left;
        node* m_right;
    };
    node* m_root;
    void AddLeafPrivate(const T& x, node* Ptr);
    void PrintInOrderPrivate(node* Ptr);
    node* ReturnNodePrivate(const T& x, node* Ptr);
    T FindSmallestPrivate(node* Ptr);
    void RemoveNodePrivate(const T& x, node* parent);
    void RemoveRootMatch();
    void RemoveMatch(node* parent, node* match, bool left);
    node* CreateLeaf(const T& x);
    node* ReturnNode(const T& x);
    void RemoveSubtree(node* Ptr);
public:
    BST();
    ~BST();
    void AddLeaf(const T& x);
    void PrintInOrder();
    T ReturnRootKey();
    void PrintChildren(const T& x);
    T FindSmallest();
    void RemoveNode(const T& x);
};
In my .cpp file I am getting errors with the following functions:
template <typename T>
template BST<T> :: node* BST<T>::ReturnNode(const T& x)
{
  return ReturnNodePrivate(x, m_root);
}
template <typename T>
template BST<T> :: node* BST<T> :: ReturnNodePrivate(const T& x, node* Ptr)
{
if(Ptr != NULL)
{
    if (Ptr -> m_data == x)
    {
        return Ptr;
    }
    else 
    {
        if (x < Ptr -> m_data)
        {
            return ReturnNodePrivate(x, Ptr -> m_left);
        }
        else 
        {
            return ReturnNodePrivate(x, Ptr -> m_right);
        }       
    }
}
else
{
    return NULL;
}
}
I am getting the same 4 errors for each function and I am confused what I am doing wrong.
- error: expected '<' before 'BST' for template BST<T>
- error: 'T' was not declared in this scope
- error: template argument 1 is invalid
- error: expected initializer before '*' token
Any suggestions on what I am doing wrong?
 
     
    