mardi 7 avril 2020

Why do I get this error when I Insert node at tail of linked list ?(hackerrank question)

Node* Insert(Node *head,int data)
{
    Node *node = new Node;
    node -> data = data;

    if (head == NULL) {
        return node;
    }
    else {
        Node *last = head;
        while (last -> next != NULL) {
            last = last -> next;
        }
        last -> next = node;
        return head; 
    }

}

Error: Solution.cpp:69:1: error: ‘Node’ does not name a type; did you mean ‘modf’? Node* Insert(Node *head,int data) Solution.cpp: In function ‘int main()’: Solution.cpp:104:41: error: ‘insertNodeAtTail’ was not declared in this scope

Aucun commentaire:

Enregistrer un commentaire