What happens when you erase a container element that contains a pointer to a dynamically allocated object?
What will be an ideal response?
Erasing an element that contains a pointer to a dynamically allocated object does not delete that object—this can lead to a memory leak. If the element is a unique_ptr, the memory would be deleted. If the element is a shared_ptr, the reference count to the dynamically allocated object would be decremented and the memory would be deleted only if the reference count reached 0.
You might also like to view...
Which of the following is considered the most effective tool in the arsenal to fight terrorism and computer crime alike?
a. USA Patriot Act b. Wiretap Act c. National Security Act d. Immigration and Nationality Act
It is ____ to terminate the last case in a switch statement with a break.
A. required B. mandatory C. a syntax error D. not necessary