title: Creating an object: with or without `new`
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3673998/what-is-difference-between-instantiating-an-object-using-new-vs-without">What is difference between instantiating an object using new vs. without</a>  </p>
  </blockquote>
  
  
  
  <p>This is probably a basic question, and might have already been asked (say, <a href="https://stackoverflow.com/q/2494471/459391">here</a>); yet I still don't understand it. So, let me ask it.</p>
  
  <p>Consider the following C++ class:</p>
  
  <pre><code>class Obj{
      char* str;
  public:
      Obj(char* s){
          str = s;
          cout &lt;&lt; str;
      }
      ~Obj(){
          cout &lt;&lt; "Done!\n";
          delete str;        // See the comment of "Loki Astari" below on why this line of code is bad practice
      }
  };
  </code></pre>
  
  <p>what's the difference between the following code snippets:</p>
  
  <pre><code>Obj o1 ("Hi\n");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Obj* o2 = new Obj("Hi\n");
  </code></pre>
  
  <p>Why the former calls the destructor, but the latter doesn't (without explicit call to <code>delete</code>)?</p>
  
  <p>Which one is preferred?</p>