title: Initialize Pointer Through Function
body: <p>I was browsing my teacher's code when I stumbled across this:</p>
  
  <p><code>Order* order1 = NULL;</code></p>
  
  <p>then</p>
  
  <p><code>order1 = order(customer1, product2);</code></p>
  
  <p>which calls </p>
  
  <pre><code>Order* order(Customer* customer, Product* product)
  {
      return new Order(customer, product);
  }
  </code></pre>
  
  <p>This looks like silly code. I'm not sure why, but the teacher initialized all pointers to NULL instead of declaring them right away(looking at the code it's entirely possible, but he chose not to).</p>
  
  <p>My question is:  is this good or acceptable code? Does the function call have any benefits over calling a constructor explicitely? And how does new work in this case? Can I imagine the code now as kind of like:</p>
  
  <p><code>order1 = new Order(customer, product);</code></p>