一般地说我们都不需要define our deconsturcor, the compile will synthesized one for us,即使我们定义了自己的析构函数,编译器还是会合成一个,调用了自己定义的后,编译器会调用自己合成的那个.
合成的destructor will no delete 指针类型的member ,so we need to redefine the destructor ,and delete this pointer by ourself.
destroying build-in type or compound type member has no effor.so no need to call there destructor.
class typy member 也不用我们去destroy,因为合成的会帮我们destroy
本文探讨了C++中默认析构函数的行为,并强调了当类包含指针成员变量时,需要显式定义析构函数来释放内存的重要性。此外,文章还提到了内置类型及复合类型成员的析构过程。
7666

被折叠的 条评论
为什么被折叠?



