I’m trying to import some c code into my c++ program. There are three lines that don’t import directly:
The first:
free(t);
The second:
new_node = (Tree *) malloc (sizeof (Tree));
The third:
Tree * delete(int value, Tree * t)
How can these be changed to work in C++?
The first two lines should be valid C++, assuming you’ve included stdlib.h, and have defined Tree as a class/struct/type somewhere.
The third line will need to be changed, since ‘delete’ is a keyword in C++ and can’t be used as a function name. Try doing a global replace in the C code and changing all instances of ‘delete’ with ‘delete_from_tree’ or something like that.