what is smart pointer & use of the smart pointer ???

Answers were Sorted based on User's Feedback



what is smart pointer & use of the smart pointer ???..

Answer / satya

Smart pointers are objects which store pointers to
dynamically allocated (heap) objects. They behave much like
built-in C++ pointers except that they automatically delete
the object pointed to at the appropriate time. Smart
pointers are particularly useful in the face of exceptions
as they ensure proper destruction of dynamically allocated
objects. They can also be used to keep track of dynamically
allocated objects shared by multiple owners.

Is This Answer Correct ?    16 Yes 0 No

what is smart pointer & use of the smart pointer ???..

Answer / swarna sekhar dhar

Smart pointers have been the subject of hecatombs of code
written and rivers of ink consumed by programmers and
writers around the world. Perhaps the most popular,
intricate, and powerful C++ idiom, smart pointers are
interesting in that they combine many syntactic and semantic
issues. This chapter discusses smart pointers, from their
simplest aspects to their most complex ones and from the
most obvious errors in implementing them to the subtlest
ones—some of which also happen to be the most gruesome.

In brief, smart pointers are C++ objects that simulate
simple pointers by implementing operator-> and the unary
operator*. In addition to sporting pointer syntax and
semantics, smart pointers often perform useful tasks—such as
memory management or locking—under the covers, thus freeing
the application from carefully managing the lifetime of
pointed-to objects

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C++ General Interview Questions

We all know that a const variable needs to be initialized at the time of declaration. Then how come the program given below runs properly even when we have not initialized p?

0 Answers  


Explain how we implement exception handling in c++?

0 Answers  


In inline " expression passed as argument are evalauated once " while in macro "in some cases expression passed as argument are evaluated more than once " --> i am not getting it plz help to make me understand....

0 Answers   College School Exams Tests, CS,


What are the differences between a struct in C and in C++?

8 Answers   Amazon, Wipro,


int main() { int i ,a[i]; i = 0; a[i] = 10; cout<< a[i] << endl; return 0; } What will be output of this program?

11 Answers   HCL, Mphasis,






Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).

0 Answers  


How many static variables are created if you put one static member into a template class definition?

0 Answers  


Explain the difference between static and dynamic binding of functions?

0 Answers  


write infinite loop in C++ which does not use any variable or constant?

3 Answers  


Why is it called c++?

0 Answers  


Which algorithm do you like the most? Why?

2 Answers   Google,


What is the array and initializing arrays in c++?

0 Answers  


Categories