top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is smart pointer in C/C++?

+1 vote
418 views
What is smart pointer in C/C++?
posted Jul 9, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

1.Smart pointer is a c++ object, it has the ownership of raw pointer. It is used to ensure the leakage of resources like memory.
2. Smart pointer is allocated in stack, which handles the heap allocated pointer.
3. We do not required to call delete in order to destruct the smart pointer. Destructor get called auto maticatically when smart pointer goes out of its scope.

Ex. Smartptr ptr( new( int));
Smartptr is the name of the class.

answer Jul 11, 2014 by Prakash Singh
...