title: Vector initialized with size, impossible to clear
body: <p>I have this declaration of a multidimensional vector</p>
  
  <pre><code>std::vector&lt; vector &lt; vector  &lt; ofxImage &gt; &gt; &gt; front_objects;
  </code></pre>
  
  <p>Then I send it to my class when creating it:</p>
  
  <pre><code>Catalog_object * temp = new Catalog_object(&amp;front_objects, numTag);
  </code></pre>
  
  <p>And then I perform the following:</p>
  
  <pre><code>Catalog_object::Catalog_object(vector&lt; vector &lt; vector  &lt; ofxImage &gt; &gt; &gt; * _front_objects, int numTag) {
      front_objects=_front_objects;
      if (front_objects-&gt;size()&lt;numTag+1) {
          front_objects-&gt;resize(numTag+1);
      }
  }
  </code></pre>
  
  <p>What I want to do is to populate the main <strong>front_objects</strong> with vectors of <strong>ofxImages</strong> from the Catalog_objects, which might share some vectors of vectors of ofxImages.</p>
  
  <p>The problem is that "sometimes" the vector is initialized with garbage and when trying to clear it with</p>
  
  <pre><code>front_objects[numTag].resize(2);
  </code></pre>
  
  <p>the program crashes with an EXC_BAD_ACCESS</p>
  
  <p>When resizing it with resize(), shouldnt it be filled with empty vectors?</p>
  
  <p>Thanks</p>
  
  <p>Marc</p>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>I tried doing like this but I get "uninitialized reference member 'Catalog_object::front_objects'".</p>
  
  <pre><code>Catalog_object::Catalog_object(vector&lt; vector &lt; vector  &lt; ofxImage &gt; &gt; &gt; &amp; _front_objects, int numTag) { // CHANGED * FOR &amp;
      std::vector&lt; vector  &lt; vector &lt; ofxImage &gt; &gt; &gt; &amp; front_objects; // CHANGED * FOR &amp;
      front_objects=_front_objects;
      if (front_objects.size()&lt;numTag+1) {
          front_objects.resize(numTag+1);
      }
      front_objects[numTag].resize(2);
  }
  
  
  std::vector&lt; vector &lt; vector  &lt; ofxImage &gt; &gt; &gt; front_objects;
  Catalog_object * temp = new Catalog_object(front_objects, numTag); // REMOVED &amp;
  </code></pre>