title: Returning a local object from a function
body: <p>Is this the right way to return an object from a function?</p>
  
  <pre><code>Car getCar(string model, int year) {
     Car c(model, year);
     return c;
  }
  
  void displayCar(Car &amp;car) {
     cout &lt;&lt; car.getModel() &lt;&lt; ", " &lt;&lt; car.getYear() &lt;&lt; endl;
  }
  
  displayCar(getCar("Honda", 1999));
  </code></pre>
  
  <p>I'm getting an error, "taking address of temporary". Should I use this way:</p>
  
  <pre><code>Car &amp;getCar(string model, int year) {
     Car c(model, year);
     return c;
  }
  </code></pre>