lundi 26 avril 2021

Random output from vector within Map C++ [duplicate]

If I wanted to take a random output from a vector and store it into a string, I would use this method:

vector<string> vec = { "Hello", "World" };
string random = vec[rand() % vec.size()];

Say if I had a map with vec stored like this:

myMap["hello"] = vec;

How would I access this vector to randomize the output of that specific key? Would it be the same concept? I've tried a few things to no avail.




Aucun commentaire:

Enregistrer un commentaire