When we define the copy constructor, is it required that we clear the contents of the object we are writing over? I am implementing a binary search tree, and wondering if I wouldn't have a memory leak unless I clean it up when implementing the copy constructor and the assignment operator.
When we define the copy constructor, is it required that we clear the contents of the object we are writing over?
At time of construction there's no content that needs to be overwritten. Just make sure you're doing all of the copies of member variables in the constructor member initializer list, rather than doing in the constructor's body.
Otherwise the compiler would generate default initialization for members, and then there could be something allocated, that actually needs to be cleared and overwritten (or deep copied).
Especially if you're dealing with pointers as you claim to do.
Best you should follow The Rule of Three (Five) to ensure everything is done consistently.