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?
10/21/2019 11:19:58 AM
Jake1 Answer
New AnswerWe 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.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message