|
I think you just have to look at it like this: you may have two distinct variables, but they have the same content (a pointer). You can delete both variables (if they're dynamic), but deleting the thangy pointed to by the pointer can only happen once. Suppose now you have a variable with a pointer to dynamic memory. When you copy that, you make a new variable, you make a new pointer to different dynamic memory, you duplicate the contents of the first dynamic memory into the second. A true, deep copy, not a copy of a reference. Then you can delete either, or both.
@Ruben. There are a couple things I'm going to approach Grumpy about when I have my basic article publisher-formatter-swiss army knife thangy done. One would be the namespaces thing and one would be the unspecified/undefined behavior thing. I need to finish my part first, though, because otherwise the author's material becomes virtually unmaintainable. I also need to solidify my perception of what constitutes a separate article and what constitutes a piece of a FAQ/Gotchas-for-Newbies piece.
|