title: c++ : Expression must be a modifiable lvalue
body: <p>I got  </p>
  
  <blockquote>
    <p>Expression must be a modifiable lvalue</p>
  </blockquote>
  
  <p>in</p>
  
  <p><code>rear-&gt;getNextNode() = &amp;node;</code></p>
  
  <p>Here is code:</p>
  
  <pre><code>using namespace std;
  #include&lt;iostream&gt;
  #include&lt;string&gt;
  
  
  class Node
  {
  
      string name;
      Node* next;
      int arrivedTime;
      int runningTime;
      char state='R';
  
  public:
  
      Node(char* name,int arrivedTime,int runningTime):name(name),arrivedTime(arrivedTime),runningTime(runningTime){}
  
      void printState()
      {
          cout &lt;&lt; "name=" &lt;&lt; name &lt;&lt; " " &lt;&lt; endl;
      }
  
      void execute()
      {
          runningTime--;
          printState();
      }
  
      bool whetherArrive()
      {
          if (arrivedTime &gt; 0)
          {
              return false;
          }
          else
          {
              return true;
          }
      }
  
      void downArrivedTime()
      {
          arrivedTime--;
      }
  
      Node* getNextNode()
      {
          return next;
      }
  };
  
  class Queue
  {
  public:
      Node* head;
      Node* rear;
      Node* p;
  
  
      void insert(Node &amp;node)
      {
          if (head == NULL)
          {
              head = &amp;node;
              rear = &amp;node;
              p = &amp;node;
  
          }
          else
          {
  
              rear-&gt;getNextNode() = &amp;node; //here hint Expression must be a modifiable lvalue
          }
      }
  
  };
  
  int main()
  {
      cout &lt;&lt; "input： process-count" &lt;&lt; endl;
      int processCount;
      cin &gt;&gt; processCount;
      for (int i = 0; i &lt; processCount; i++)
      {
          cout &lt;&lt; "input：process-name arrivedTime runningTime" &lt;&lt; endl;
          char name[20];
          int arrivedTime;
          int runningTime;
          cin &gt;&gt; name &gt;&gt; arrivedTime &gt;&gt; runningTime;
          Node node(name, arrivedTime, runningTime);
      }
  }
  </code></pre>
  
  <p><code>rear-&gt;getNextNode()</code> return a pointer to <code>Node</code>, and then set the point <code>&amp;node</code>. What's wrong here?</p>