I'm trying to make a simple binary search tree. Each node has a char data type, and a pointer to a char. For the tree class, this information needs to be filled in when inserting items. I am having troubles inserting the character array. Here is my class. I am trying to keep this simple, no complications needed.
The program just crashes, and I've searched and found that the crash occurs on the call to setCode() for a node. Anyone know what I am doing wrong?Code:#include <cstring> class bNode { private: char ch; char *code; bNode *left, *right; public: bNode() { ch = 0; } ~bNode() { delete code; } char getCh() { return ch; } char* getCode() { return code; } void setCh(char c) { ch = c; } void setCode(char *c) { code = new char[strlen(c)+1]; strcpy(code, c); } };