Happy new years for everyone! :)
I could do better things in the first day of the year but i'm trying to implement the linked lists and recursion together.
I just thought that how I can achieve to write a function that calculates the even numbers in a linked list with recursion.
void List:: findingEvens(Node* n, Node*& newHead){
if(n == NULL)
return;
else
if(n-> data % 2 != 0)
findingEvens(n-> next);
else{
if(!newHead){
newHead = n;
}
else{
Node* temp =head;
for(;temp->next;temp=temp->next){
temp = temp -> next;
}
temp-> next = n;
findingEvents(n-> next);
}
}
}
The problem is that in my h class I add the following as it should be
void findingEvens(Node* n);
However this makes me error which says that error: ‘Node’ has not been declared Actually I have a Node struct after the definition of this function in h class.
Is the implementation of the recursive function wrong? Any help will be appreciated, happy new year again :)