Im not quite sure, I worked with my tutor and this is what he came up with. The insertnode handles inserting value m into a node which is passed from the user, all values get eventually sorted into a list.
insert() call at line 47 and 58 should have been insertnode(). If that call is insertnode(), then I have found some problem with your implementation with it.
1 2 3 4 5 6 7
void insertnode(nodeptr& head, double m){
nodeptr p = head;
nodeptr k = p;
if (!p){
nodeptr n = new node(m, NULL);
}
...
You should do something with new node pointed to by variable n in line 5 or else it will cause memory leak and that new node will not be inserted to the list.
That if statement must not be removed since it will handle the case that head is NULL or in the case for first insert. You cannot do 2nd and succeeding insert if you can't fix the case of the first insert. What I said you must do something is that, perhaps assign that new node pointed to by n to head.
Do you understand what this insertnode() does? I suggest you understand it step by step since you can't understand what other people are suggesting here.