你怎么就一根筋呢? STL之vector and string用还是不用

本文探讨了在决定动态开辟内存空间后所承担的责任,包括确保内存适时被正确删除及使用正确的删除方式,强调了现代库如vector和string的便利性,简化了内存管理过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The minute you decide to use new for a dynamic allocation,you adopt the following responsebilities:

只要你决定动态开辟内存空间,你就有活干了,下面的就是:

1 You must make sure that somebody will later delete the allocation.

你必须确保有哪个老几会把他在不用的时候删除,也许这个人就是你自己.

2 You must ensure that the correct form of delete is used.Only once deletion and for an array allocation,delete[] is required.

你必须确保它们被正确的删除,只能而且只能被删除一次,有时候还有一次性删除一个数组.

That's quite a set of responsebilities,and I can't understand why you'd want to adopt them if it wasn't necessary.

你要管一大堆屁事,我真是搞不懂在不是不需那样做的情况下你还屁颠屁颠的去使用它干吗?

Thanks to vector and string.It isn't necessary anywhere near as often as it used to be.

感谢vector,感谢string.它几乎总是必要的.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值