mercredi 21 avril 2021

Vector of pointers vs Vector of objects vs Vector on the heap

What is the use case of the following examples:-


vector<Object> collection;

vector<Object> *collection = new vector<Object>

vector<Object*> collection;(creating the object on the heap)

When do I need to create a vector of pointers over a vector of objects and doesn't the vector (or any STL container) allocate the elements on the heap?

Aucun commentaire:

Enregistrer un commentaire