I am currently studying for a programming exam and am supposed to write a destructor for the class "BTree" in one of the exercises. The following code is a Binary Tree. I don't know what should be in the body of the destructor because I haven't learned that properly yet. I think there should be something in there with delete because I also created dynamic objects on the heap with new. Thanks in advance.
class BTree
{
public:
vertex* root;
BTree()
{
root = NULL;
};
~BTree() {
};
bool isEmpty() { return root == NULL; }
vertex* Nikita = new vertex("Nikita");
vertex* Vendor = new vertex("Vendor");
vertex* faehrt = new vertex("faehrt");
vertex* nach = new vertex("nach");
vertex* Alexendria = new vertex("Alexandria");
void main() {
root = node(node(create(), Nikita,node(create(), Vendor, create() ))
, faehrt,
node(create(), nach, node(create(), Alexandria, create() ))
);
cout << empty (right(root)) << endl;
cout << value(left(root)) << endl << endl;
};
class vertex{
public:
int key;
string data;
vertex* leftChild;
vertex* rightChild;
vertex* parent;
int height;
vertex(string data){
key = ID;
this->data = data;
leftChild = NULL;
rightChild = NULL;
parent = NULL;
ID++;
};
vertex(){
key = 0;
leftChild = NULL;
rightChild = NULL;
parent = NULL;
};
~vertex(){
};
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#include "BTree.h"
int main() {
// Aufgabe 1
BTree B;
B.main();
// Aufgabe 2
BTree C = B;
C.print();
// Aufgabe 3
BST D;
D.main();
D.print(D.root);
D.sortvector(); //neu hinzugefügt
// Aufgabe 4
// D.PrintLayers();
}