title: Accessing vector outside of scope of if loop in C++
body: <p>First off, I'm new to C++ and very accustomed to working in MatLAB. My code will probably want to make seasoned C++ users shoot me in the face, but it looks like this:</p>
  
  <p>EDIT: I have heavily edited my code snippet. The following is a cleaned up, generalized example of what I'm trying to accomplish.</p>
  
  <pre><code>int main()
  {
  
  
  int t = 0;
  vector&lt;int&gt; Pad_Ref_Vec; //initialize vector. Required size unknown
  
  
       for (int n = 0; n &lt;= 10; n++)
       {
  
            if (t == 0)
            { 
                 vector&lt;int&gt; Pad_Ref_Vec(100); //at this point in the code, i know the size i need this vector to be
  
                 for (int i = 0; i &lt; 100; i++)
                 {
                      Pad_Ref_Vec[i] = i;         
                 }
  
             }
             else
             {
  
              //do some operation using the values of Pad_Ref_Vec created in the above 
              //if statement  
  
              }
  
       t++;
  
       }
  
      return 0;
  }
  </code></pre>
  
  <p>If I do this, the vector Pad_Ref_Vec does not read [0 1 2 3 4 5 ... ... ] after the if statement, but goes back to its previous form (after the first initialization before the <code>for</code> loop) which is just a vector of size 0</p>
  
  <p>I'm finding it hard to believe that something so simple is turning out to be such a hassle. Thanks in advance for any constructive tips.</p>