Im having a little trouble understanding how to code a linked list in C++ Code. I understand how the Linked List works, but i am having trouble writting it in code. I have a class and i have several member functions in the class. I am having a difficult time coding them. Im new to programming, i have just under a years experience, any help would be appreciated. I understand the concepts im having trouble thinking and making sence of how to code it. The preconditions and posts are there for each function. HELP ME PLZ!!!
CODE
//This is the implementation file for the class ListType
#include <iostream>
#include <cstddef> //to access NULL
#include "ListType.h"
typedef NodeType* NodePtr;
typedef int ItemType;
struct NodeType
{
ItemType item;
NodePtr next;
};
List::List()
//Post: listPtr is set to NULL.
{
listPtr = NULL;
}
//*****************************************************************
List::List(const List& otherList)
//Copy-constructor for ListType
{
//FILL IN CODE
}
//*****************************************************************
//This one in particuallar im confused on
bool List::IsThere(ItemType item) const
//Post: If item is in the list IsThere is
// True; False; otherwise.
{
//FILL IN CODE
}
//*****************************************************************
void List::Insert(ItemType item)
//Pre: item is not already in the list.
//Post: item is the first item in the list.
{
//FILL IN CODE
}
//*****************************************************************
void List::Delete(ItemType item)
//Pre: item is in the list.
//Post: item is no longer in the list.
{
//FILL IN THE CODE
}
//*****************************************************************
void List::Print() const
//Post: Items in the list are printed to the screen.
{
//FILL IN THE CODE.
}
//*****************************************************************
int List::Length() const
//Post: Number of items have been counted; result returned
{
//FILL IN CODE
}
//*****************************************************************
List::~List()
//Post: All the components are deleted.
{
//FILL IN CODE
}