|
-
May 26th, 2008, 02:59 PM
#14
Re: Avoiding Dynamic Allocation
More importantly in this case, you'll have to define the operator= and copy constructor in such a way that no two objects of a class share the same pointer. Typically this means allocate a new dynamic object in both cases; and in the case of operator=, also first delete the existing object (if any).
If your operator= and copy constructor are properly defined, then it will be impossible for a destructor call to result in multiple deletion because there will be only one object holding each dynamically allocated memory block.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|