title: C++ "new" in the Java way
body: <p>Bjarne Stroustrup, being asked if...</p>
  
  <p>«<b><i>Can I use "new" just as in Java?</i></b>» </p>
  
  <p>He answered «<b><i>Sort of, but don't do it blindly and there are often superior alternatives.</i></b>» and showed how to do that, with the following code:</p>
  
  
  
  <pre class="lang-cpp prettyprint-override"><code>void compute(cmplx z, double d)
  {
      cmplx z2 = z+d; // c++ style
      z2 = f(z2);     // use z2
  
      cmplx&amp; z3 = *new cmplx(z+d);    // Java style (assuming Java could overload +)
      z3 = f(z3);
      delete &amp;z3; 
  }
  </code></pre>
  
  <p>I tougth that whatever the language be, the <b>"new"</b> works in the same manner i.e. allocates space for an object and assigns a pointer with the address of that object. </p>
  
  <p>I'm wondering what's the difference (in terms of performence or whatsoever) between:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>MyClass *ptr = new MyClass();
  ...
  delete ptr;
  </code></pre>
  
  <p>and </p>
  
  <pre class="lang-cpp prettyprint-override"><code>MyClass&amp; ref = *new MyClass();
  ...
  delete &amp;ref;
  </code></pre>
  
  <p><br>
  Any ideas about this?</p>
  
  <p><br>
  Thank you</p>