Binary Search Tree Destructor

前端 未结 6 1369
太阳男子
太阳男子 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:43

    How about automating it:

    class BinSearchTree
    {
        std::auto_ptr   left;
        std::auto_ptr   right;
    
        BinSearchTree(BinSearchTree const&);
        BinSearchTree& operator=(BinSearchTree const&); // private
    };
    

    Now destruction is automatic. :-)

提交回复
热议问题