how to create linked list node without specific node names code example
Example 1: how to use a new node c++
struct node(){
int key;
node *next;
node(x){
key = x;
next = NULL;
}}
node *temp = new node(key);
temp -> next = head;
Example 2: linked list class c++ basic implementation
template<typename T>
class list {
public:
struct node {
T value;
node* next;
};
list() : hd(nullptr), tl(nullptr) {}
node* head() { return hd; }
node* tail() { return tl; }
void insert(node* prior, T value);
node* at(int i);
void erase(node* prior);
void clear();
void push_back(T value);
void pop_back();
void push_front(T value);
void pop_front();
int size();
private:
node* hd, tl;
}