title: dereferencing in a vector of pointers to objects
body: <p>I'm trying to access the object (called a Vector) pointed to by a pointer held in a vector container, but I can't seem to get to it.</p>
  
  <p>Here are the important code snippets:</p>
  
  <pre><code>int main{
      Vector&lt;double&gt;* test = new Vector&lt;double&gt;(randvec&lt;double&gt;());
  
      test-&gt;save();
  
      cout &lt;&lt; Element::vectors[0];
  return 0;
  }
  </code></pre>
  
  <p>Where <code>Vector</code> is a template class, <code>randvec&lt;T&gt;()</code> returns a reference to a vector, <code>save()</code> is</p>
  
  <pre><code>template &lt;class T&gt;
  void Vector&lt;T&gt;::save()
  {
      vectors.push_back(this);
  }
  </code></pre>
  
  <p>and vectors is <code>static std::vector&lt;Element*&gt; vectors;</code> defined in Element.h, the base class of Vectors.</p>
  
  <p>Am I going about this all wrong? I'm trying to contain all the elements of a derived class in a static data member of the base class by using a vector of pointers to the main class. </p>
  
  <p>My output from main() might tell you what's going on – I get the pointer <code>0x1001000a0</code>. However, if I try to dereference that pointer, I get the following error:</p>
  
  <pre><code>error: no match for 'operator&lt;&lt;' in 'std::cout &lt;&lt; * Element::vectors. 
  std::vector&lt;_Tp, _Alloc&gt;::operator[] [with _Tp = Element*, _Alloc = std::allocator&lt;Element*&gt;](0ul)'
  </code></pre>
  
  <p>Why can't I dereference this pointer?</p>