Want to add additional strings to a vector of string vectors in c++ -


I have a dozen string vectors and I want to put them all in a big vector and then add a string For each of the young children again

Suppose that vector 1 has "1" element as an element - vector 2 has "1" and "2" elements, vector 3 In the form of "1", "2", and "3" elements in ... ... in vector 12 as "1", "2", ... and "12" elements

< P> Vector in "large" Tier 1 to 12 (or signal for each of them, which is the easiest)

I want to go through the big elements of each vector and 1 to 12 vectors are "a" and "b" "I want to add.

> Is it possible, or should the part of vector 2 be overwritten by joining for vector 1?

If the vector of large vector strings is a vector of pointers that is fine.

Edit (some code, not all):

  vector & lt; Vector & lt; String & gt; * & Gt; AllTypesOfGamesDealt; Of vector & lt; String & gt; FB_BJ_BS; Of vector & lt; String & gt; BJ_BS; FB_JJ_BS.push_back ("Free bet"); FB_BJ_BS.push_back ("Blackjack"); FB_JJ_BS.push_back ("Big Six"); AllTypesOfGamesDealt.push_back (& ​​amp; FB_BJ_BS); BJ_BS.push_back ("Blackjack"); BJ_BS.push_back ("Big Six"); AllTypesOfGamesDealt.push_back (& ​​BJ_BS); For (int i = 0; i & lt; allTypesOfGamesDealt.size (); ++ i) {Vector & lt; String & gt; * TempGamesDealt = allTypesOfGamesDealt [i]; (* TempGamesDealt) .push_back ("Break"); }  

^ The problem with that code is that I think I'm adding a copy of the vector to "break", not the actual vector.

Your question is no longer answered, C ++ string of your memory Manage and do not overwrite anything that has already been done Allocated for another variable I believe that they actually allocate a certain amount of memory and increase it if they require more, Instead of allocating them as much as they need, why That is not to allocate a little more than the requirement is relatively expensive to re-cover the memory and better to use something. Assuming that I understand what you mean,

  std :: vector & lt; Std :: string & gt; a; A.push_back ("hell"); A.push_back ("world"); A [0] .append ("o");  

There will be no problem.

Edit:

Even with nesting, it will still be fine, for two reasons. First of all, the vector generally assigns more memory to it like the string and for the same reason even if you wanted to kill the capability and If you wanted to add another element, then it will use a managed function to allocate memory again, so that you will be able to ensure that you are not overwriting anything else.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -