linked list insertion in cpp code example

Example 1: insertion sort c++

void InsertionSort(int* A, int size)
{

  int i, key, j;  
    for (i = 1; i < N; i++) 
    {  
        key = A[i];  
        j = i - 1;  
  
        /* Move elements of arr[0..i-1], that are  
        greater than key, to one position ahead  
        of their current position */
        while (j >= 0 && A[j] > key) 
        {  
            A[j + 1] = A[j];  
            j = j - 1;  
        }  
        A[j + 1] = key;  
    }  

}

Example 2: how to use a new node c++

struct node(){
  int key; 
  node *next;
  node(x){  
    key = x;
    next = NULL;     
}}
// after you take a input of a linked list .
// creating a new node.
node *temp = new node(key);  // tem pointer pointing towards the new node. 
temp -> next = head; // inserting the mew node in the start .