title: Can I implement a push_back method for linked list in that way?
body: <p>I've already been doing push_back methods for link lists like that:</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Node{
  public:
      int data;
      Node* next;
      Node(int data,
   Node* next = nullptr){
          this-&gt;data = data;
          this-&gt;next = next;
      }
  };
  
  Node* head = nullptr;
  
  void push_back(int data){
      if(head == nullptr){
          head = new Node(data);
      }
      else{
          Node *current = head;
          while(current-&gt;next != nullptr){
              current = current-&gt;next;
          }
          current-&gt;next = new Node(data);
      }
  }
  </code></pre>
  <p>But I wonder if I could add a node after another one (I am talking about this piece of code see below):</p>
  <pre><code>    else{
          Node *current = head;
          while(current-&gt;next != nullptr){
              current = current-&gt;next;
          }
          current-&gt;next = new Node(data);
      }
  </code></pre>
  <p>Not using the condition :</p>
  <pre><code>while(current-&gt;next != nullptr)
  {current = current-&gt;next;}
  </code></pre>
  <p>,but instead doing:</p>
  <pre><code>while(current != nullptr){current = current-&gt;next;}
  </code></pre>
  <p>When doing that we equalize the current pointer to a nullptr. Is it possible from that point to add a new Node at the end and linking that Node to the whole list?</p>
  <p>Or the concept of <code>while(current != nullptr)</code>
  is not favorable for push_back()?</p>