title: CPP - using * or & to return address
body: <p>I am writing  a code to make a linked list.
  one of the function I wrote in order to make a linked list easier in the main function was[node is the name of a struct conatains a.data b.pointer name next) :</p>
  
  <pre><code>    node&amp; create_node(int value)
      {
      node newitem;
      newitem.data=value;
      newitem.next=NULL;
      return (newitem);
      };
  </code></pre>
  
  <p>When I write the function like this everything is ok but I want to write the function header as :</p>
  
  <pre><code>    node * create_node(int value)
  </code></pre>
  
  <p>But when I write it that way and I write </p>
  
  <pre><code>  return *newitem;
  </code></pre>
  
  <p>I get an error.
  I wanted to ask why the VS shows me an error in the 2nd way and what is the difference between using * and &amp; [I already read here about references but I don't understand why one should use it in functions as , from what I understood using references takes additional space and not contributing ] .</p>
  
  <p>edit :thank you for help, when I posted this  it was before I even ran a test on the main function only tried to avoid mistakes before compilation .
  It took me some time but now I see the fundamental mistake I did .</p>