jeudi 8 juin 2017

Effect of equal an existing vector or map to an empty curly brackets

I have 2 containers,a std::vector and a std::map:

vector<int> my_vector;
map<string,int> my_map;
my_vector.push_back(3);
.
.elaboration of my_vector;
.

my_map["Hello"]=1;
.
.elaboration of my_map
.

Later I do:

my_map={};
my_vector={};

This should make the 2 containers 2 empty containers. Is it right? And more, what does happen to previous memory pointed from my_map and my_vector?

Thanks in advance! (I'm on C++11)

Aucun commentaire:

Enregistrer un commentaire