I am having problems here if I want to check if eerste points to nothing I get
Blockquote
Unhandled exception at 0x003921c6 in
Bank.exe: 0xC0000005: Access violation
reading location 0xccccccd0.
and I am kinda wondering why he justs skips the if statement or doens’t stop when the object eerste points to nothing
Bank::Bank()
{
LijstElement *eerste = NULL;
LijstElement *laatste = NULL;
}
Rekening * Bank::getRekening(int rekNr)
{
if(NULL != eerste)
{
LijstElement *nummer = eerste;
while(nummer->volgende!= NULL)
{
Rekening *een = nummer->getRekening();
if(een->getRekNr()==rekNr)
{
return een;
}
else
{
nummer = nummer->volgende;
}
}
}
return NULL;
}
I think you have to change
because they are probably declared in your class as member variables and you’re declaring them as local variables.
As Fred Larson proposed, you can also use initialization lists.