C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 15, Problem 15.15E
Program Plan Intro

Erasing a container element that contains a pointer to a dynamically allocated object.

When we erase the container element containing pointer to a dynamically allocated object then object has to be destroyed by calling destructor, which release all the resources such as memory else they will remain forever with the container.
In order to release memory we must delete every container element container pointer, then erase the vector and swap as shown in code below

Blurred answer
Students have asked these similar questions
vWhat happens when an object such as an array is no longer referenced by a variable?
Submarining is a phenomenon that occurs when the pointer disappears when you move it too rapidly.
What header file must you #include in order to define vector objects?
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT