template<class T>
void BST<T>::insert(const T& el)
{
BSTNode<T> *p = root, *prev = 0;
// find a place for inserting new node;
while (p != 0)
{
prev = p;
if (p->key < el)
{
p = p->right;
}
else
{
p = p->left;
}
}
if (root == 0) // tree is empty;
{
root = new BSTNode<T>(el);
}
elseif (prev->key < el)
{
prev->right = new BSTNode<T>(el);
}
else
{
prev->left = new BSTNode<T>(el);
}
}
Any help would be very much appreciated.
I have created BST's with simple data types and it works fine, but when I try with Cats or Dates (test case with Dates) I get compile errors.
I get the error C2784 mostly.