Will this memory be freed properly?

I have a pointer to a pair, suppose std :: pair <A *, B *> * pointerpair. I allocated its memory, and after using the pair, I call delete pointerpair.

Will it also cause delete A and delete B and completely free the memory?

If I just call delete A and delete B but not delete pointerpair, is that a memory leak?

+3
source share
2 answers

no.............

+4
source

No. He will not do this automatically. You must delete it explicitly.

+2
source

Source: https://habr.com/ru/post/1766904/


All Articles