Original Post
I have been writing a program that simulates population growth (for my AI), And i am having some problems with the the dynamic memory.
*code is cut down*
Any help would be very appreciated
[edited by - Prod on July 22, 2002 1:35:10 AM]
//First i start off like this
cPerson *person[1];
//The program will not start when i leave this code uncomminted
int Male = NULL;
int Female = NULL;
for (int i = 0; i < Population; i++)
{
if (person[i]->bGender == true) Male = i;
if (person[i]->bGender == false) Female = i;
}
//This is how i create a person
Population = Population + 1;
person[Population] = new cPerson();
//I think there is an error on how i delete also since a few
//seconds after the program quites i get a windows error from
//the program
void Death(cPerson guy)
{
if(guy.Age >= 100) delete[] &guy
Population = Population - 1;
}
void Kill(cPerson guy)
{
delete[] &guy
Population = Population -1;
}