Binary Search Tree Destructor

前端 未结 6 1379
太阳男子
太阳男子 2021-02-04 13:51

Working on implementing my own BST in C++ for the experience of dealing with such structures.

I\'ve had trouble implementing a destructor. I found in my studies, that on

6条回答
  •  爱一瞬间的悲伤
    2021-02-04 14:54

    The problem is that in you class you probably declared that the node structure has a custom destructor, but you don't provide it so at link time the compiler is complaining a piece is missing.

    If you don't need any more custom code in the destructor then you can just remove the destructor from the struct declaration and your program will compile fine.

    Note however that there is no problem at all to have a destructor of to destory children nodes (see Brendan Long answer). If you ran into problems while attempting that the issue you faced must me something else.

提交回复
热议问题