I''m learning linked lists (no STD, just basic linked lists), and I''m attempting to add a new node at the end of list. No matter what I do, this freezes my computer!
this is the code:
void The_Asteroids::AddAst()
{
Tail = Tail->NewAst(Tail);
}
An_Asteroid *An_Asteroid::NewAst(An_Asteroid *curr)
{
if(Next==NULL)
{
Next=new An_Asteroid;
Next->Prev=curr;
Next->Next=NULL;
return Next;
}
return NULL;
}
The_Asteroids class is the list of An_Asteroid class. It have Head, Tail, and Current. An_Asteroid is storage for data on each asteroids, sort of like an array.
When this is called, the game freezes, along with my computer. Can you explain why this is happening, and what is the correct way to do it?
Thanks
You know your game is in trouble when your AI says, in a calm, soothing voice, "I''m afraid I can''t let you do that, Dave"