Dynamic memory | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Dynamic memory

Ok, so this is where it gets hard, so.. I have a question. I thought of an example about new and delete about the heap. Someone tell me if itā€™s correct. I have 3 classes, bow, sword, and gun. I choose one, should I use delete on the others because I donā€™t need to use it?

21st Oct 2019, 11:19 AM
Jake
1 Resposta
+ 1
We delete objects not classes.šŸ˜„ if you make objects of these classes dynamically , use them and no longer need then you may delete them to free the resources. Always remember to free allocated memory before the program exits to avoid memory leakes.
21st Oct 2019, 1:41 PM
šŸ‡®šŸ‡³OmkaršŸ•‰
šŸ‡®šŸ‡³OmkaršŸ•‰ - avatar