Did you like how we did? Rate your experience!

4.5

satisfied

46 votes

How do you appraoch Allocating memory with pointers ?

You try not to use bare pointers. If possible you use one of the pointer classes that have been added to the std library: unique_ptr, shared_ptr or weak_ptr. If that is not possible and you need to use a pointer you analyze your code and be sure that the memory is released. If you are using one of the smart pointers types I mentioned above the design of the destructor is more trivial because the smart pointer will take care of releasing memory for you.

100%
Loading, please wait...