title: C++ Builder how to build dynamic Objects with vector?
body: <p>I am developing IOS application in C++ Builder . My question is how to build TImages in a for loop. I declared the vector in public : </p>
  
  <pre><code>#include &lt;vector&gt;
  
  std::vector&lt;TImage*&gt; Image(c); // public declaration 
  
  void __fastcall TForm1::Button2Click(TObject *Sender)
  {
   for (int i = 0; i &lt; c ; i++){
  
      c = 5 // c should be send to te array
      Image[i] = new TImage(this); // I tried it this way but when i click the button i get an acess violence error
      Image[i]-&gt;Parent = BoardItem ;
      Image[i]-&gt;Height = 20 ; 
      Image[i]-&gt;Width = 20 ; 
     }
  }
  </code></pre>
  
  <p>So how do i create Images in a for loop using vector ?</p>
  
  <p><a href="https://stackoverflow.com/questions/34141850/dynamic-alocation-an-array-of-images-in-c-builder">Dynamic alocation an array of Images in C++ Builder</a> I looked up the last answer to that question but there isn't described how to do it in a loop . </p>