GeekInterview.com
Series: Subject: Topic:
Question: 49 of 267

Smart Pointers

What is Smart Pointer in C++?
Asked by: rdurgalakshmi | Member Since Jun-2010 | Asked on: Sep 14th, 2010

View all questions by rdurgalakshmi   View all answers by rdurgalakshmi

Showing Answers 1 - 1 of 1 Answers
ajrobb

Answered On : Sep 23rd, 2010

View all answers by ajrobb

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.

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.