Hello so it seems that my code will execute but will not return the max node or anything, extremely frustrating because I cant seem to figure this out if you need additional code please ask.
int LinkedList::maxNode(listNode *p)
{
int current = p->val;
int next;
if (p->next == NULL)
{
return current;
}
else
{
next = maxNode(p->next);
}
if (current > next) {
return current;
}
else {
return next;
}
}
int LinkedList::findMaxNode()
{
return maxNode(head);
}
that was the function and this is the main
case 'M':
case 'm':
Mylist.findMaxNode();
break;
and this is the header file please don't give me the answer just show me my error
class LinkedList
{
protected:
struct listNode
{
struct listNode* next;
double val;
};
public:
listNode* head;
LinkedList();
LinkedList(const LinkedList&);
~LinkedList();
void appendNode(double);
void insertNode(double);
void insertNodeByPosistion(double, int);
void deleteNodeByPosition(int pos);
void destroyNode(double);
void reverseList(listNode*);
bool searchList(int);
int maxNode(listNode *p);
int findMaxNode();
void displayList(listNode*);
int operator[](int);
};