C++ Linked List

im having trouble with the test program for my linked list


#include "HeadNodeList.h"
#include <iostream>
using namespace std;

int main()
{
  int a, b, c, d, e;
  HeadNodeList list;
  cout<<"Enter 5 number: ";
  cin>>a>>b>>c>>d>>e;
  list.insert(a);
  list.insert(b);
  list.insert(c);
  list.insert(d);
  list.insert(e);
  list.display();
  list.remove(c);
  list.remove(e);
  list.dispaly();
  return 0;
}

heres the header


#ifndef HEADNODELIST
#define HEADNODELIST

#include <iostream>
using namespace std;

template <typename ElementType>
class HeadNodeList
{
  private:
    class Node
    {
      public:
        //------ DATA MEMBERS OF Node
        ElementType  data;
        Node   *     next;
        //------ Node OPERATIONS
        Node(ElementType newData, Node * link = NULL): data(newData), next(link)
        {
        }
    };//--- end of Node class 

    
    typedef Node * NodePointer;
    
  public:
    //------ HeadNodeList OPERATIONS  
    HeadNodeList();

    HeadNodeList(const HeadNodeList<ElementType> & original);

    ~HeadNodeList();

    bool isEmpty() const;

    int getSize() const;

    void insert(ElementType item);

    void remove(ElementType item);

    void display(ostream & out) const;

    const HeadNodeList<ElementType> & operator= (const HeadNodeList<ElementType> & original);

  private:
    bool search(ElementType item, NodePointer & trailPtr);

    //------ DATA MEMBERS OF HeadNodeList
    NodePointer     first;
    int             size;
}; //--- end of HeadNodeList class

template <typename ElementType>
HeadNodeList<ElementType>::HeadNodeList()
{
  NodePointer Head = new Node(NULL);
  first = Head;
  size = 0;
}

template <typename ElementType>
HeadNodeList<ElementType>::HeadNodeList(const HeadNodeList<ElementType> & original)
{
  size = original.size;
  if (original.first->next == NULL)
    first->next = NULL;
  else
  {
    NodePointer origPtr = original.first->next;
    NodePointer newPtr = new Node(origPtr->data);
    first->next = newPtr;
    for (origPtr = origPtr->next; origPtr !=NULL; origPtr = origPtr->next)
    {
	newPtr->next = new Node(origPtr->data);
	newPtr = newPtr->next;
    }
  }
}

template <typename ElementType>
HeadNodeList<ElementType>::~HeadNodeList()
{
  NodePointer deletePtr = first->next;
  while (deletePtr != NULL)
  {
	 first->next = deletePtr->next;
	 delete deletePtr;
	 deletePtr = first->next;
  }
}

template <typename ElementType>
bool HeadNodeList<ElementType>::isEmpty() const
{
  return (first->next == NULL);
}

template <typename ElementType>
int HeadNodeList<ElementType>::getSize() const
{
  return size;
}

template <typename ElementType>
void HeadNodeList<ElementType>::insert(ElementType item)
{
  NodePointer trailPtr = NULL;
  if (!search(item, trailPtr))
  {
    NodePointer newPtr = new Node(item);
    size++;
    if (trailPtr==NULL)
    {
      newPtr->next = first->next;
	first->next = newPtr;
    }
    else
    {
      newPtr->next = trailPtr->next;
      trailPtr->next = newPtr;
    }
  }
}

template <typename ElementType>
void HeadNodeList<ElementType>::remove(ElementType item)
{
  NodePointer deletePtr, trailPtr = NULL;
  if (search(item, trailPtr))
  { 
    if (trailPtr == NULL)
    {
      deletePtr = first->next;
	first->next = deletePtr->next;
    }
    else
    {
	deletePtr = trailPtr->next;
	trailPtr->next = deletePtr->next;
    }
    delete deletePtr;
    size--;
  }
}

template <typename ElementType>
void HeadNodeList<ElementType>::display(ostream & out) const
{
  NodePointer currentPtr = first->next;
  while (currentPtr != NULL)
  {
    out << currentPtr->data << "  ";
    currentPtr = currentPtr->next;
  }
}

template <typename ElementType>
const HeadNodeList<ElementType> & HeadNodeList<ElementType>::operator= (const HeadNodeList<ElementType> & original)
{
  if (this != &original)
  {
    NodePointer deletePtr = first->next; //delete old list, if any
    while (deletePtr != NULL)
    {
      first->next = deletePtr->next;
      delete deletePtr;
      deletePtr = first->next;
    }
    size = original.size;
    if (original.first->next == NULL)
      first->next = NULL;
    else
    {
      NodePointer origPtr = original.first->next;
      NodePointer newPtr = new Node(origPtr->data);
      first->next = newPtr;
	for (origPtr = origPtr->next; origPtr !=NULL; origPtr = origPtr->next)
	{
	  newPtr->next = new Node(origPtr->data);
	  newPtr = newPtr->next;
	}
    }
  }
  return * this;
}

template <typename ElementType>
ostream & operator<<(ostream & out, const HeadNodeList<ElementType> & list)
{
  list.display(out);
  return out;
}

template <typename ElementType>
bool HeadNodeList<ElementType>::search(ElementType item, NodePointer & trailPtr)
{
  NodePointer currentPtr = first->next;
  while(currentPtr != NULL && currentPtr->data < item)
  {
    trailPtr = currentPtr;
    currentPtr = currentPtr->next;
  }
  return (currentPtr != NULL && currentPtr->data == item);
}
#endif

so, uhh what is your problem?

you just told us it doesn’t work somehow

when i compile i get

HeadNodeList.cpp: In function ‘int main()’:
HeadNodeList.cpp:8: error: ‘HeadNodeList’ undeclared (firstuse this function)
HeadNodeList.cpp:8: error (Each undeclared identifier is reported only once for each function it appears in.)
HeadNodeList.cpp:8: error: parse error before ‘;’ token
HeadNodeList.cpp:11: error: ‘list’ undeclared (first use this function)

those were some simple bugs

#include "HeadNodeList.h"
#include <iostream>
using namespace std;

int main()
{
  int a, b, c, d, e;
  HeadNodeList<int> list; // didn't specify the type, HeadNodeList is a template class...
  cout<<"Enter 5 number: ";
  cin>>a>>b>>c>>d>>e;
  list.insert(a);
  list.insert(b);
  list.insert(c);
  list.insert(d);
  list.insert(e);
  list.display(cout); // forgot to mention cout
  list.remove(c);
  list.remove(e);
  list.display(cout); // you spelled display wrong, and forgot to mention cout
  return 0;
}