Insertion at head

what is wrong with my code

hello @nishiumrao
it is correct.

it is giving compilation error

image
just define a constructor in ur class

is it necessary to define a constructor?

no not necessary ,
but because here u r passing data in constructor ,it is mandatory
image

temp->data = data;
can we write like this?

yeah… … … …