In C++, any general guidelines for handling memory allocation/deletion? -


Whatever I am asking is a link to the website that I still have to find. But Java is coming from the background, what are the general guidelines for memory allocation and deletion in C ++? I think I can add all kinds of memory leaks in my application. I know there are many forms of smart pointers, and you can also mention them to me, but I would like to focus on standard C ++ pointers.

  • Disable copy of container object in rare cases. Apply the PIN so that it can point to the object, but never allow the owner to copy the object without copying the underlying object.
  • The last two rules ensure that you delete Can not make copies of the pointers pointing to the memory that has gone
  • Do not try to apply the reference count if you need to calculate the reference then the pointer uses the smart pointer class and joins it.
  • I have made sure that those rules are that you can use the raw pointer safely and efficiently, and if you want to break it, instead of those rules, a smart pointer Use the.


    Comments