title: Deleting a pointer to a vector
body: <p>I have a <code>const std::vector&lt;double&gt; *vecPtr</code> inside a class. I want to correctly deallocate memory, so what should my <code>destructor</code> look like?</p>
  
  <p>I tried <code>~ClassA() { delete[] vecPtr; }</code> , but i get an error </p>
  
  <pre><code>*** Error in `./test': free(): invalid pointer: 0x00007fff8c643a98 ***
  Aborted (core dumped)
  </code></pre>
  
  <p>Does <code>delete[]</code> work only if vector is filled with pointers?</p>
  
  <p>EDIT:</p>
  
  <p>I use <code>vecPtr</code> like this: <code>vecPtr = &amp;vec;</code></p>
  
  <p>If i use just <code>delete</code> i get <code>*** Error in ./test': double free or corruption (fasttop): 0x00000000008fcb20 ***</code></p>