title: segmentation fault pushback an object created inside loop of its class function c++
body: <p>i m trying to create and insert into vector inside a for loop but i m getting segmentation fault i know why and i know the reason but what i m asking is how can i prevent it , 
  i m getting error because end of the scope created object dies....</p>
  
  <pre><code>void Board::Resize()
  {
      for(int i=0; i&lt;Row_Size; i++)
      {
          for(int j=0; j&lt;Column_Size; j++)
          {
              Cell copyCell(i,static_cast&lt;char&gt;('a'+j),'.');
  
              BoardCells[i].push_back(copyCell);
          }
      }
  }
  </code></pre>
  
  <p>Board class has a vector of vector of Cells in private</p>
  
  <pre><code>vector&lt;vector Cell&gt; myCells;
  </code></pre>
  
  <p>and Cell class have in private</p>
  
  <pre><code>int row;
  char column;
  char status;
  </code></pre>
  
  <p>its a smiple class not much variables</p>
  
  <p>if i cant use pushback like this than how can i do ? (filling with objects inside vector without segmantation fault )</p>