how much does the default destructor do

后端 未结 5 2124
死守一世寂寞
死守一世寂寞 2021-02-14 04:11

Does the default destructor in C++ classes automatically delete members that are not explicitly allocated in code? For example:

class C {
  public:
    C() {}
           


        
5条回答
  •  执念已碎
    2021-02-14 04:49

    Anything that you call new for must have a corresponding delete. If you didn't call new to create an instance of something then you don't have to call delete.

提交回复
热议问题