title: error: invalid conversion from ‘Node*’ to ‘int’
body: <p>Working in C++ here. I am trying to develop a specific program that creates a BST from its preorder traversal. Here's the first batch of code:</p>
  
  <pre><code>class Node {
  
   private:
     int val;     
     Node *left;      
     Node *right;     
  
   public:
     Node () : val(0), left(NULL), right(NULL) {}         
     Node (int v) : val(v), left(NULL), right(NULL) {} 
     Node (int v, Node *l, Node *r) : val(v), left(l), right(r) {}
     Node&amp; operator = (Node&amp; rhs) {               
       if (&amp;rhs == this) return *this;
       val = rhs.val;
       left = rhs.left;
       right = rhs.right;
       return *this;
     }
  
  }*root; 
  </code></pre>
  
  <p>I've taken out some of the functions but that's the basics. Now here's the other piece of code:</p>
  
  <pre><code>Node *temp = new Node();
  
    if (preorder[trav] &lt;= N)
    {
       temp = root;
       root-&gt;goLeft(pre_ordered, traverse);
       traverse++;
    }
  
    else
    {
       temp = root;
       root-&gt;goRight(pre_order, traverse);
       traverse++;
    }
  </code></pre>
  
  <p>However, I then get " error: invalid conversion from 'Node*' to 'int' " on the line "temp = root". Any ideas? It seems to me I'm setting one node equal to the other so I don't understand what's wrong. Looked online and found nothing helpful. Some similar errors, but just different enough to not be useful.</p>
  
  <p>I'll be upfront that this is for a school assignment so I'm not looking for direct answers. Just hints about what I need to change or where I need to look would be great! Thanks.</p>
  
  <p><strong>EDIT</strong>: Exact error is:</p>
  
  <pre><code>main.cpp:160:15: error: invalid conversion from ‘Node*’ to ‘int’ [-fpermissive]
        temp = root;
             ^
  </code></pre>
  
  <p><strong>EDIT</strong> I found it. I apologize.</p>
  
  <p>I was stupid and didn't look hard enough to find that I was redefining "temp" as an int in the main function. Sorry for wasting your time guys.</p>
  
  <p>Can't answer my own question since not enough rep.</p>