This is the header file provided by my instructor.

//
// unsortedlist.h
//

#ifndef UNSORTED_LIST_H
#define UNSORTED_LIST_H

struct UnsortedListNode		// Description of list node
{
  char	ch;			// Stores one character input from file
  UnsortedListNode* nextPtr;	// Stores address of next node
};

class UnsortedList		// Linked list implementation of unsorted list
{
  private:
    UnsortedListNode* headPtr;	// Points to NULL or head of list
	int num;		// Stores number of items in list
	
  public:
    UnsortedList();		// Default constructor - makes list empty
	void InsertNewChar(char anotherChar);	// Adds anotherChar to head of list
	char DeleteFirst();	// Returns char on head of list, deleting that node
	bool IsEmpty();		// Returns true if empty, false otherwise
	bool IsFull();		// Returns true if full, false otherwise
	~UnsortedList();	// Deallocates any remaining nodes on list
};

#endif

This is my implementation of the header file
I am having problems with the deleteFirst() function. What am I doing wrong there.
I have tried for three days to get this to compile.
All this program does is pulls in chars one by one puts them in a list and then reads them from the list and stores them in reverse order in a new file.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cmath>
#include <new>
#include <cstddef>
#include "unsortedlist.h"

using namespace std;

UnsortedList::UnsortedList()
{
   headPtr = NULL;
   num = 0;
}

void UnsortedList::InsertNewChar(char anotherChar)
{
   UnsortedListNode* tempPtr = new UnsortedListNode;   
   
   tempPtr->ch = anotherChar;
   tempPtr->nextPtr = headPtr;
   headPtr = tempPtr;
   num++;
   
}

char UnsortedList::DeleteFirst()
{
   //char ch;
   UnsortedListNode* tempPtr = headPtr;
   
   headPtr = headPtr->nextPtr;
   headPtr = tempPtr->ch;
   num--;
   delete tempPtr;
   return ch;
}

bool UnsortedList::IsEmpty()
{
   return (headPtr == NULL);
}

/*bool UnsortedList::IsFull()
{
   return (num == 
}*/

void UnsortedList::~UnsortedList()
{
   //UnsortedListNode ch;
   
   while (!IsEmpty())
   {
      DeleteFirst();
   }
}

try this:

char UnsortedList::DeleteFirst()
{
   char ch;
   UnsortedListNode* tempPtr = headPtr;
   
   tempPtr = headPtr;
   ch = tempPtr->ch;
   headPtr = headPtr->nextPtr;
   num--;
   delete tempPtr;
   return ch;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.