How this feature works?

Given the following code, which gave rise to questions

#include <iostream>
#include <fstream>
using namespace std;

void insert(list*& p, char value); 

struct list
 char symbol;
 list* next;

int main()
 setlocale(LC_CTYPE, "Russian");
 list* first = nullptr;

 char value;
 cout << "Enter a character ";
 cin >> value;
 insert(first, value);

void insert(list*& p, char value) // 
 list* newP = new list;
 if (newP != NULL) //is there a place? 
 newP->symbol = value;
 newP->next = p;
 p = newP;
 cout << "insert Operation failed" << endl;

1. The insert function takes two parameters, for which the first parameter? Why refer to the insert function pointer to reference the first parameter?
2. list* first = nullptr - it Seems in this line creates a pointer to the first element of a single-linked list, why would it assign a void?
3. What is happening in this line? list* newP = new list;
April 19th 20 at 12:20
1 answer
April 19th 20 at 12:22
Questions to ask the developer of this code, for a common response to all 3 points, because it is written code. Background is unknown.
  1. The first parameter is passed a reference to a pointer "head of list", function insert creates the new list item and inserts it at the beginning, therefore, it is necessary to change the value of pointers to the head
  2. "C++ nullptr implicitly converts to the appropriate pointer type". Assigned emptiness because it is empty, and the variables must be initialized
  3. Creates a new list item

Find more questions by tags C++