C++ 回忆录9 deconstructor

本文探讨了C++中默认析构函数的行为,并强调了当类包含指针成员变量时,需要显式定义析构函数来释放内存的重要性。此外,文章还提到了内置类型及复合类型成员的析构过程。

一般地说我们都不需要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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值