Implementation of Singly Linked List (C++) I tried to implement a singly linked list myself, sorry it is not commented but I think it should be pretty self-explanatory, if not feel free to comment. I know that using namespace std; is not optimal, but I figured it would be okay for this little example. Same goes for defining the class right in the main.cpp file (and in the declaration). I have two questions:

Is this even a correct implementation or did I miss something important? The methods worked as expected for me.
Would it make any sense to use smart pointers here? If yes, why? And what would I have to change for it to work?

Thank you for your time, I would appreciate any answers! :)
#include &lt;iostream&gt;

using namespace std;

struct Node
{
int32_t data;
Node* next;
};

class linked_list
{
public:

linked_list() : last{ NULL }, tmp{ NULL }, begin{ NULL } {};

~linked_list()
{
    clear();
}
void push_back(int32_t data)
{
    if (begin)
    {
        tmp = new Node;
        tmp-&gt;data = data;
        tmp-&gt;next = NULL;

        last-&gt;next = tmp;
        last = tmp;
        tmp = NULL;
    }
    else
    {
        begin = new Node;
        begin-&gt;data = data;
        begin-&gt;next = NULL;
        last = begin;
    }
}
void display_all()
{
    if (begin)
    {
        tmp = begin;
        while (tmp)
        {
            cout &lt;&lt; tmp-&gt;data &lt;&lt; endl;
            tmp = tmp-&gt;next;
        }
        tmp = NULL;
    }
    else
    {
        cout &lt;&lt; &quot;List is empty.&quot; &lt;&lt; endl;
    }
}
void clear()
{
    while (tmp != last)
    {
        tmp = begin-&gt;next;
        delete begin;
        begin = tmp;
    }
    delete last;
    begin = NULL;
    tmp = NULL;
    last = NULL;
    }
private:
    Node* last;
    Node* begin;
    Node* tmp;
};

PS:
(Someone told me this would fit better on this site than on Stack Overflow so I am reposting.)
struct Node would benefit from its own constructor. As a side note, if you don't want to expose struct Node to the client (and trust me, you don't), better make it private to class LinkedList.

tmp doesn't deserve to be a class member. It is strictly local to each method.

DRY. push_back could and should be streamlined:
  struct Node * tmp = new Node(data);
  if (begin) {
      last-&gt;next = tmp;
  } else {
      begin = tmp;
  }
  last = tmp;


display_all should not print anything on the empty list. The caller might be greatly confused.

clear could and should be streamlined. Run the loop till nullptr:
  while (begin) {
      struct Node * tmp = begin-&gt;next;
      delete begin;
      begin = tmp;
  }
  last = nullptr;

As a side note, prefer nullptr to NULL.