The STL contains a vector class. What is the main issue with storing objects in the vector class as opposed to pointers?

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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?

Post by answerhappygod »

The Stl Contains A Vector Class What Is The Main Issue With Storing Objects In The Vector Class As Opposed To Pointers 1
The Stl Contains A Vector Class What Is The Main Issue With Storing Objects In The Vector Class As Opposed To Pointers 1 (31.79 KiB) Viewed 24 times
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!
Post Reply