Hence, the whole statement means:

"Call the constructor of the Node class and pass it ‘9’ as a parameter. After constructing the object in memory, give me the starting memory address of the object. That address will be stored in the pointer variable newNode."

To create an object of int type in the same manner, we can write as:

int * i  =  new  int ;

Previously, we used the same technique to allocate memory for an array of ints as:

int *  i  =  new  int [10] ;

Now after the node has been created, how the node is fit into the chain of the linked list.

Fig 2. Insertion of new node in the linked list

 

BACK

HOME

NEXT