title: Can a pointer be placed on heap memory (C++)?
body: <p>I wrote some code in which I attempted to create a pointer on the Free store(Heap memory). I think it's impossible but I tried regardless.</p>
  
  <p>The code below is basically creating a vector of pointers on the heap and then making those pointers in the vector point to some ints on the heap. I want to know if those pointers in the vector called vec are on the heap? I also wanted to know what is the proper way to free up space allocated  when using a vector like this. The last delete statement was crashing the program so I commented it out. I don't know if there is a memory leak.</p>
  
  <pre><code>    vector&lt;int*&gt; *vec = new vector&lt;int*&gt;();
      vec-&gt;push_back(new int(1));
      vec-&gt;push_back(new int(2));
      vec-&gt;push_back(new int(3));
      cout &lt;&lt; (*vec)[0] &lt;&lt; " " &lt;&lt; (*(*(vec))[0]) &lt;&lt; endl;
      cout &lt;&lt; (*vec)[1] &lt;&lt; " " &lt;&lt; (*(*(vec))[1]) &lt;&lt; endl;
      cout &lt;&lt; (*vec)[2] &lt;&lt; " " &lt;&lt; (*(*(vec))[2]) &lt;&lt; endl;
      delete (*vec)[0];
      delete (*vec)[1];
      delete (*vec)[2];
      //delete [] vec;
  </code></pre>