-
BSTree
Can anyone see what the problem with this may be?
Code:
template <class T>
BSTree<T>& BSTree<T>::operator= (const BSTree<T>& bst)
{
if (this != &bst)
{
if (!isEmpty())
clear(root);
root=copyTree(bst.root);
}
return *this;
}
template <class T>
BTNode<T> *copyTree (BTNode<T> *treeRoot)
{
BTNode<T> *newTree, *lptr, *rptr;
if (treeRoot==NULL)
return NULL;
else
{
treeCopy=new BTNode<T>;
treeCopy->info=treeRoot->info;
treeCopy->lptr=copyTree(treeRoot->left);
treeCopy->rptr=copyTree(treeRoot->right);
}
return treeCopy;
}
-
Does that code compile?
I am confused as to what the difference is between lptr (seemingly a local variable AND member of BSTree) and left, and rptr and right (seemingly a local variable AND member of BSTree).