What is the correct way of using an auto_ptr on dynamically allocated arrays?

Posted by LoudNPossiblyRight on Stack Overflow See other posts from Stack Overflow or by LoudNPossiblyRight
Published on 2010-06-01T00:33:19Z Indexed on 2010/06/01 0:43 UTC
Read the original article Hit count: 193

Filed under:
|

If i use auto_ptr to hold a pointer to a dynamically allocated array, when the auto_ptr gets killed it will use a plain delete operation and not delete[] thus not deleting my allocated array.

How can i (properly) use auto_ptr on dynamically allocated arrays?

If this is not possible, is there another smart pointer alternative for dynamically allocated arrays?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c++

Related posts about auto-ptr