I'm using a structure called tree like this...\
1 2 3 4 5 6 7 8
|
struct tree
{
int grade;
char name[20];
tree* right;
tree* left;
tree(tree*, tree*, int, char*);
};
|
Then, I'm using a class to do some operations with the tree I'll be working with like this...
1 2 3 4 5 6 7
|
class Ctree
{
public:
Ctree();
~Ctree();
...
}
|
Right now it may all seem confusing but I can't seem to figure out how to write a proper destructor for my dynamically allocated nodes. I can't figure out the logic. I can't add any other structure and class member functions other than the ones provided for me which are...
for the structure, 1) 4 argument constructure.
for the class, 1) constructor, 2) destructor, 3) adding a node, 4) viewing the tree, 5) adding an item (for recursion). As stated before, I can't add any other member functions, therefore, recursion seems to be out of the question + I can't give my destructor any arguments. I've been trying at it for a loooong time now and I don't seem to get it right. Please help me...