I'm trying to do a lab for class and despite my professor's lecture and the accompanying reading, I'm having issues figuring out syntax. If someone can help with one of the functions, I feel like I can figure out the rest.
This is the header
#pragma once
#include <string>
using namespace std;
struct ListNode
{
public:
ListNode( const string& theString, ListNode* pNext = NULL )
{
word = theString;
pNextNode = pNext;
}
string word;
ListNode* pNextNode;
};
//add a node (pNode) at the head of the list.
//return a pointer to the head node
ListNode* addFront( ListNode* pHead, ListNode* pNode );
//add a node (pNode) at the tail of the list.
//return a pointer to the head node
ListNode* addEnd( ListNode* pHead, ListNode* pNode );
//remove (and cleanup after) the node at the head of the LinkedList (pHead)
//return a pointer to the head node
ListNode* removeFront( ListNode* pHead );
//remove (and cleanup after) the node at the tail of the LinkedList (pHead)
//return a pointer to the head node
ListNode* removeEnd( ListNode* pHead );
//traverse the LinkedList (pHead) and delete all nodes
//return a pointer to the head node
ListNode* removeAllNodes( ListNode* pHead );
//traverse the LinkedList (pHead) and write out all the words in the list
//separated by a space
void printNodeReport( ListNode* pHead, ostream& out );
and this is the cpp in which I need to implement stubs
#include "LinkedList.h"
#include <string>
#include <sstream>
//add a node (pNode) at the head of the list.
//return a pointer to the head node
ListNode* addFront( ListNode* pHead, ListNode* pNode )
{
//stub
return pHead;
}
//add a node (pNode) at the tail of the list.
//return a pointer to the head node
ListNode* addEnd( ListNode* pHead, ListNode* pNode )
{
//stub
return pHead;
}
//remove (and cleanup after) the node at the head of the LinkedList (pHead)
//return a pointer to the head node
ListNode* removeFront( ListNode* pHead )
{
//stub
return pHead;
}
//remove (and cleanup after) the node at the tail of the LinkedList (pHead)
//return a pointer to the head node
ListNode* removeEnd( ListNode* pHead )
{
//stub
return pHead;
}
//traverse the LinkedList (pHead) and delete all nodes
//return a pointer to the head node
ListNode* removeAllNodes( ListNode* pHead )
{
//stub
return pHead;
}
//traverse the LinkedList (pHead) and write out all the words in the list
//separated by a space
void printNodeReport( ListNode* pHead, ostream& out )
{
out << "Here's the list: ";
ListNode* pCurr = pHead;
while( pCurr != NULL )
{
out << pCurr->word << " ";
pCurr = pCurr->pNextNode;
}
out << "EOL \n";
}