|
-
March 30th, 2007, 10:59 PM
#6
Re: Smart pointer vs Auto pointer
Originally Posted by JVene
A vector of pointers to an object is better constructed as a vector of auto_ptrs to those objects, as you won't have to 'run though and delete' every entry when the vector falls out of scope.
As previously stated, most compilers will not even let you compile a vector of auto_ptr.
Even compilers that do allow you to compile it, will usually fail to compile as soon as you add code that tries to add content to the container.
For more about smart pointers, check out the following link:
http://axter.com/smartptr/
If you're storing a container of smart pointers that's pointing to an abstract class, you should try using a clone smart pointer, as listed in above link.
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
|