title: c++ right way to initialize a vector of a struct
body: <p>i searched a lot here, but there is no right explanation for me, for an advanced newbie in c++. I worked before with vector of structs  and now I get segmentation faults...</p>
  
  <p>Thats why I want to know how such objects actually works and if it is the right the way I am doing!</p>
  
  <p>I have a struct like</p>
  
  <pre><code>struct numberOfSpecies {
     int predator;
     int prey1;
     int prey2;
  };
  </code></pre>
  
  <p>and a vector of it:</p>
  
  <pre><code>std::vector&lt;numberOfSpecies&gt; size;
  </code></pre>
  
  <p>Before I resize it and fill it with values. </p>
  
  <pre><code>size.resize(100);
  </code></pre>
  
  <p>what is actually this doing? Is this right for a struct?
  It looks like it is initialized with zeros... </p>
  
  <p>Now I am doing this like:</p>
  
  <pre><code>size[t].predator=0;
  size[t].prey1=0;
  size[t].prey2=0;
  
  for(int k = 0; k &lt; N; ++k){
    size[t].predator++;
    size[t].prey1++;
    size[t].prey2++;
  }
  </code></pre>
  
  <p>Is this right? Where are possible issues? How to do it better?</p>