Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews C Plus Plus Language Interviews:C++ Access ControlC++ COM ActiveXC++ ConstructorsC++ ContainersC++ Exception HandlingC++ FriendC++ InheritanceC++ Inline FunctionC++ New And DeleteC++ Operator OverloadingC++ Pointers & FunctionsC++ ProgrammerC++ ReferencesC++ Static DataC++ SyntaxC++ TemplateC++ Type CheckingC++ Virtual Functions
Copyright © 2018. All Rights Reserved
C++ Pointers & Functions Interview Question:
What is smart pointer?
Submitted by: AdministratorSmart pointers are objects which store pointers to dynamically allocated (heap) objects. They are like built-in C++ pointers. However, they automatically delete the object pointed to at the appropriate time. They are useful as they ensure proper destruction of dynamically allocated objects (Exceptions). They can also be used to keep track of dynamically allocated objects shared by multiple owners.
They appear as owning the object pointed to and are responsible for deletion of the object when it is no longer needed.
The smart pointer library provides five smart pointer class templates:
scoped_ptr : Simple sole ownership of single objects. Noncopyable.
scoped_array: Simple sole ownership of arrays. Noncopyable.
shared_ptr: Object ownership shared among multiple pointers
shared_array: Array ownership shared among multiple pointers.
weak_ptr: Non-owning observers of an object owned by shared_ptr.
intrusive_ptr: Shared ownership of objects with an embedded reference count.
These templates are designed to complement the std::auto_ptr template.
Submitted by: Administrator
They appear as owning the object pointed to and are responsible for deletion of the object when it is no longer needed.
The smart pointer library provides five smart pointer class templates:
scoped_ptr : Simple sole ownership of single objects. Noncopyable.
scoped_array: Simple sole ownership of arrays. Noncopyable.
shared_ptr: Object ownership shared among multiple pointers
shared_array: Array ownership shared among multiple pointers.
weak_ptr: Non-owning observers of an object owned by shared_ptr.
intrusive_ptr: Shared ownership of objects with an embedded reference count.
These templates are designed to complement the std::auto_ptr template.
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.