well they are both array and yes they both are set to point to something. i had badwords point to a class of badwords which consist of two strings and then i have sentence point to an array of words that make up a sentence.
Printable View
well they are both array and yes they both are set to point to something. i had badwords point to a class of badwords which consist of two strings and then i have sentence point to an array of words that make up a sentence.
Then one or the other (or, I suppose, both) is already delete[]d when you get to the destructor. You wrote the code, so presumably you know which.
hmm i believe its badwords because when i // it doesnt give me the double free error but i dont see where i deallocate it
I am aware that past performance is no guarantee of future growth, but: perhaps you deallocate another pointer that you have set equal to badwords?
What do you mean, you use the destructor? Do you call it explicitly? You're not supposed to do that.
If you use a safe delete function, then you won't get the delete error.
possibly
Code:void DeletePtr(void* ptr)
{
delete ptr;
ptr = 0;
}
void DeletePtrA(void* ptr)
{
delete []ptr;
ptr = 0;
}
why a reference?
Maybe I am the confused one at this point. What purpose does your function actually serve?
well im done with this whole thing thanks for all the help you guys i got it working 100% no problems or anything thanks i learned a lot too.
Why a reference? If you want to change the parameter that gets passed in, how else would you do it?
The best I can figure, perhaps he is of the .NET school of thought wherein things are reference counted and its a crap shoot knowing whether or not they still exist in memory until you zero them. But even at that... *shrug* who cares.
no, I never use pointer references in my code, and everything works out fine.
those are the functions I use to free memory. I don't know, but through the debugger this works fine. Stepping through the code produces no incorrect behavior.