title: Instantiate a class on stack, where var is defined in header
body: <p>I am currently trying to get into writing proper C++ code (getting it running was ok for some small prototypes, but it's been ugly).</p>
  
  <p>I recently realized the difference of heap and stack instantiation (O  m = new O() vs. O m()).</p>
  
  <p>Now I have a class, where the header file defines a variable, which holds an table definition.</p>
  
  <blockquote>
    <p>ChunkLoader.hpp:</p>
    
    <blockquote>
      <blockquote>
        <p>TablePartion *tablePartial_;</p>
      </blockquote>
    </blockquote>
    
    <p>ChunkLoader.cpp:</p>
    
    <blockquote>
      <blockquote>
        <p>ChunkLoader() { tablePartial_ = new TablePartial(true, 0, 1); }</p>
      </blockquote>
    </blockquote>
  </blockquote>
  
  <p>Now I want to instantiate the tablePartial on the stack, but I cannot use:
  <code>TablePartial tablePartial_(true, 0, 1);</code></p>
  
  <p>I am totally  blind? How can I allocate tablePartial_ on the stack?
  Or I am getting it totally wrong, and I cannot use in the constructor since it would be out of scope after the constructor and thus be freed? But since I read that stack variables are better performance-wise, I'd like to use stack instantiation (and getting red of <code>delete</code>).</p>
  
  <p>Main reason: stack overflow told me to get rid of pointers when ever possible. :)</p>