class SortedLinkedList
{
private:
typedefstruct ptrNode //container for a node
{
string name; //name of node
ptrNode* next; //points to next node
};
ptrNode* head; //beginning of a list; same thing as listData in book
ptrNode* tail; //end of a list
ptrNode* currentPos; //current position in list
int length;
public:
SortedLinkedList(); //constructor
~SortedLinkedList(); //destructor
bool IsFull() const; //tells if list is full
bool Empty() const { return head == NULL; } //checks if list is empty; true when head == NULL
int GetLength() const; //returns length of list
string GetItem(const string&, double& timeTaken); //returns a string if it exists
void PutItem(const string&, double& timeTaken); //adds an item to list
void DeleteItem(const string&, double& timeTaken); //deletes an item from list
void ResetList(); //empties the list
string GetNextItem(); //returns the next string in the list
void Print(); //displays all items in list
void Generate(constint); //special driver command //generates random strings
};
And the problem I am having with it is somewhere in here, but the IDE shows no squiggly lines pointing out what exactly is the problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void SortedLinkedList::Print()
{
currentPos = head;
if(currentPos != NULL) { //makes sure there is place to start
while(currentPos->next != NULL) {
cout << currentPos->name << " ";
currentPos = currentPos->next;
}
cout << currentPos->name;
}
else {
cout << "There are no values in the list to Print!";
}
}