Here let me re post what I meant.
Code:
void setCode(const char *c)//Make this const
{
delete [] code;//each time you were reassigning this you were creating a memory leak without delete
code = new char[strlen(c)+1];
strcpy(code, c);
}
Also in your constructor I would do this
Code:
bNode()
{
char = 0;
code = 0;
}
And in the destuctor
Code:
~bNode()
{
delete [] code;
}
I would also make your return c and code functions const.
Code:
char getCh() const { return ch; }
char* getCode() const { return code; }
One more thing
Code:
void setCh(const char c) { ch = c; }
//make this parameter const as well