The STL contains a vector class. What is the main issue with storing objects in the vector class as opposed to pointers?
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
The STL contains a vector class. What is the main issue with storing objects in the vector class as opposed to pointers?
The STL contains a vector class. What is the main issue with storing objects in the vector class as opposed to pointers? Vectors grow and shrink dynamically making many copies of the objects. Vectors will not delete this memory when they are destroyed, so you have to be certain to delete the contained objects before deleting the vector. The objects contained in the vector are copies and will never be as good as the real thing. Objects use more memory and could cause a stack overflow. None of these.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!