Memory leak in C++ and How to avoid it?

You should use smart pointers, if your purpose is just to avoid memory leak.

https://en.cppreference.com/book/intro/smart_pointers
Last edited on
I think the answer is not necessarily as simple as that. If you can avoid using pointers at all that is often even better. And when people recommend smart pointers I think they mean std::unique_ptr 99% of the time.
Last edited on
OP original post removed.......
Dear seeplus

Thank you for your supporting message about the fact.

Dear Peter87

As mentioned by seeplus, the original post was removed.
The original was elememtary question about new/delete memory management and omission of delete statement.

I agree with you, because smart pointer is not a perfect solution for memory leak and has unique problems.
Last edited on
Ah, that explains it. It has been a while since I used this site so I had forgotten it could be like that sometimes.
Sorry for the inconvenience, kind regards.
Last edited on
Topic archived. No new replies allowed.