Created
May 3, 2023 14:43
-
-
Save earayu/93f26c3af0c210ea1e4c79120119e67a to your computer and use it in GitHub Desktop.
book notes
Resource Management:
malloc/free不会掉用构造函数和析构函数;
new/delete、new[]/delete[]要成对出现,但是实际代码中很难保证正确性;
最好的办法是RAII原则,对象的生命周期和它的作用域保持一致。一些组件实现了RAII,比如shared_ptr.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Types:
