list of vectors (a vector of n vectors of m elements)

I create a list of vectors (a vector of n vectors of m elements).
std::vector <std::vector <int> > vsFA (n, std::vector<int>(n));
How I assign values? I try below, but not worked

void armazenaFA( std::vector <int> &vFA) // this function only knows about vFA
{ vsFA[n] [m]= simTime().dbl();
OR
vsFA[n].push_back(simTime().dbl());

}
I create a list of vectors (a vector of n vectors of m elements).

It might be a typo, but I wanted to point out that this isn't what you did here:
std::vector <std::vector <int> > vsFA (n, std::vector<int>(n));

To answer your question though, you should use the "std::vector::push_back()" method. Try not to think of the container classes as arrays, i.e. unless you know definitively that the memory reallocation is slaughtering your performance, there is usually no reason to declare the size of the vector when you construct it. Let the containers themselves worry about their size, that's half the reason they are so useful.
Topic archived. No new replies allowed.