Smart Pointers

What is Smart Pointer in C++?

Questions by rdurgalakshmi   answers by rdurgalakshmi

Showing Answers 1 - 3 of 3 Answers

ajrobb

  • Sep 23rd, 2010
 

Something like std::auto_ptr<> template class. These are essential in objects with more than one item on the heap. If a constructor fails, previously allocated objects and base classes are destroyed properly. A simple pointer is not an object and not protected in this way. Being an object, std::auto_ptr<>, will be destroyed and its destructor will delete the allocated object (not an array of objects).

Other smart pointers, not provided by the standard, can support objects in containers. These might use reference counting for efficient copying. Accessors can check the volatile reference counter to prevent modification of a shared object.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions