title: Taking address of temporary
body: <p>I am trying to assign the return value of my function to a node, which is a pointer. I have tried it both with and without '&amp;' but non of them seem to work. I am currently getting the error in the title. Without the '&amp;'  get a "cannot convert node to *node in assignment" error</p>
  
  <pre><code>   class Node{
  
      public:
      int value;
      Node *left, *right;
  
      Node(int x, Node *l, Node *r){
          value = x;
          left = l;
          right = r;
      }
  };
  
  class Tree{
  
  public:
      Node *root;
      Tree(Node *r){
          root = r;
      }
  
      void add(int num){
         cout &lt;&lt; "adding" &lt;&lt; endl;
          root = add(root, num);//error occurs here
  }
  
  private:
      Node add(Node *parent, int num){
  
          cout &lt;&lt; "im in..." &lt;&lt; endl;
  
          if(parent == root &amp;&amp; root == nullptr){
             cout &lt;&lt; "root" &lt;&lt; endl;
              Node n(num, nullptr, nullptr);
              return n;
          }
  
          if(parent == nullptr){
              Node next(num, nullptr, nullptr);
              cout &lt;&lt; "actually adding" &lt;&lt; endl;
              return next;
  
          }
          else if(num &gt; parent-&gt;value){
             cout &lt;&lt; "bigger" &lt;&lt; endl;
              parent-&gt;right = add(parent-&gt;right, num);
          }
          else {
              cout &lt;&lt; "smaller" &lt;&lt; endl;
              parent-&gt;left = add(parent-&gt;left, num);
          }
      }
  };
  
  int main(){
  
      Node n1(100, nullptr,nullptr);
  
      Tree tree(&amp;n1);
      tree.add(1);
  
          return 0;}
  </code></pre>