"Mohsen" <ja*******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hello everyone,
In my program, I have the 'Record class' as follow:
class Record
{
public:
int ID;
int PS[M];
int PD[M];
int Sex;
};
I have also defined the Animal as follows:
Record *Animal=new Record [NoAnimal];
Consider using NumAnimal or NumAnimals insteads of NoAnimal. I mean,
"number" doesn't even have an "o" in it. And if this isn't the number of
animals, then why are you allocating the array that size?
Could anybody let me know what I should use to make the 'Animal'
free? Is it just "delete [] Animal;" or I should add anything more?
delete[] Animal;
is fine in this case. Even if Record had a custom destructor, you would
still use
delete[] Animal;
which would call the custom destructor on each instance.
Also, I would probably make Sex an enum instead of an int. Unless a sex of
3 has any meaning to you.
>
Thanks,
Mohsen