Why doesn't the C++ default destructor destroy my objects?

前端 未结 13 2110
刺人心
刺人心 2020-12-14 06:59

The C++ specification says the default destructor deletes all non-static members. Nevertheless, I can\'t manage to achieve that.

I have this:

class N         


        
13条回答
  •  春和景丽
    2020-12-14 07:25

    It is incorrect to say that the destructor deletes members. It invokes the destructor of each member (and base class), which for built-in types (like pointers) means doing nothing.

    Matching news with deletes is your responsibility (either manually, or with the help of smart pointers).

提交回复
热议问题