dimanche 2 août 2015

how to change C to C++ codes

i been coding a linked list program and i have this issue changing a certain code i use in c to c++. please how do i write this c code

   void insert_first (int value)
{
    a++;
    node *new_node =(node *) malloc (sizeof(node));
    new_node->data=value;
    new_node->next=NULL;
    if(root!=NULL)
    new_node->next=root;
    root =new_node; 
}

in a c++ program. i am still new to c++. i specifically want to change this line of code.

 node *new_node =(node *) malloc (sizeof(node));

thanks in advance.

Aucun commentaire:

Enregistrer un commentaire