Apparently my previous pointer was not set to anything. |
The only place in your code where the values are set is here:
1 2 3 4 5 6 7
|
Person::Person(char& s, int& i)
{
status = s;
island = i;
next = NULL;
previous = NULL;
}
|
By the way, nowadays, you should be using
nullptr
rather than
NULL
here.
In the other parts of the code where you are constructing the list, then you should be in a position to set the
next
and
previous
pointers to the required values so the list functions properly in both forward and reverse.
Just reading through the code, you have a lot of functions which promise to return a value but do not in fact do so, for example:
1 2 3 4
|
char Person::setStatus(char& s)
{
status = s;
}
|
These may seem innocuous enough, but this omission (of the
return value;
) can cause program crashes, so should be fixed. The appropriate solution here would be to change the type to void:
1 2 3 4
|
void Person::setStatus(char& s)
{
status = s;
}
|