Quote:
|
Originally Posted by DaWei
Look at it this way: suppose I get a pointer to dynamic memory. Then I copy that pointer to another. Then I free the first. Then I attempt to free the second (which, as a copy of the first has already been freed).
|
I see what you mean. But I have a (newbish it seems) question:
Since the functions in the class do not copy the pointers, but the contents of the arrays indicated by the pointers, how does the deallocation of the 'o' object's 'ch' variable affect the 'b' object's 'ch' variable? I thought that they were a different thing.
To be more clear, I thought this thing happens: When a new stash is created, it has it's own unique 'ch' pointer variable in it. So, when I use the 'insertstring' function (which uses the 'add' function) which is used in the '=' overloaded operator, as far as I can see in my code, only the contents of the pointers are copied, and not the pointers themselves.
TheDark
told me this would happen, but it seems I don't really know how to fix it.
I am cearly missing something important here. Could you provide me with more information, or at least give me a code example?