recursion - c++ calling a recursive function that returns an object -


i'm writing .cpp file linked list class, , helper function insert returns pointer node. here i've written far:

void linkedlist::insert(course* newcourse) {     course *temp = newcourse;      temp = insertafter(head_ptr, newcourse); }  //insert's helper function course linkedlist::*insertafter(course *current_ptr, course *newcourse) {  if (current_ptr == nullptr) {     current_ptr = newcourse;     return nullptr; }  else if (newcourse->coursenumber < current_ptr->next->coursenumber) {     newcourse->next = current_ptr->next;     current_ptr = newcourse;     return nullptr; }  else     return insertafter(current_ptr->next, newcourse); } 

i have 2 questions, how call helper function, , suppose return after hit end of list, , after insert node


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -