Working on implementing my own BST in C++ for the experience of dealing with such structures.
I\'ve had trouble implementing a destructor. I found in my studies, that on
You can have a recursive destructor; what you can't do is delete the same object twice.
A typical way to delete a tree in C++ might be something like this:
BinSearchTree::~BinSearchTree()
{
delete _rootNode; // will recursively delete all nodes below it as well
}
tNode::~tNode()
{
delete left;
delete right;
}
Regarding the unresolved external error -- is that error thrown when you try to compile/link the program? If so, it's probably because the code for the tNode class (and in particular the tNode destructor, if you declared one) doesn't exist or isn't getting compiled into your project.