If I have structure: /* Linked list structure */
struct list { struct list *prev; int data; struct list *next; } ** *node = NULL, *first = NULL, *last = NULL, *node1 = NULL, *node2 = NULL**; class linkedlist { public: /* Function for create/insert node at the beginning of Linked list */ void insert_beginning() { **list *addBeg = new list;** cout << "Enter value for the node:" << endl; cin >> addBeg->data; if(first == NULL) { addBeg->prev = NULL; addBeg->next = NULL; first = addBeg; last = addBeg; cout << "Linked list Created!" << endl; } else { addBeg->prev = NULL; first->prev = addBeg; addBeg->next = first; first = addBeg; cout << "Data Inserted at the beginning of the Linked list!" << endl; } } What is the SYNTAX difference between creating a new node (with 2 pointers and data) and just a single pointer apart from node, to use in same program. (Difference between bolded parts)
int n;) or on the heap (e.g.int *p = new int;)?