Ordered Linked list using classes

Here is the code that I've written. It would be used to add an object of class Character. The only argument passed is a pointer(Character *newCharacter) to the character class object. I've declared Character *head in the private of CharacterList. When I run this code the compiler gives me an error in while, else and if loop saying: class "Character" has no member next. can anyone elp me please?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  bool CharacterList::addCharacter(Character *newCharacter)
{
	Character *temp, *back;

	if(head == NULL)
	{
		head = newCharacter;
	}

	else
	{
		temp = head;
		back = NULL;
		while((temp != NULL) &&  (temp < newCharacter))
		{
			back = temp;
			temp = temp->next;
		}

		if(back == NULL)
		{
			newCharacter->next = head;
			head = newCharacter;
		}

		else
		{
			back->next = newCharacter;
			newCharacter->next = temp;
		}

		return true;
	}

}
1
2
3
struct Character{
   Character *next; //¿do you have this?
};
Topic archived. No new replies allowed.