The following section summarizes the different kinds of smart pointers that are available in the Windows programming environment and describes when to use them.C++ Standard Library Smart Pointers:Use these smart pointers as a first choice for encapsulating pointers to plain old C++ objects (POCO). unique_ptr Allows exactly one owner of the underlying pointer. Use as the default choice for POCO unless you know for certain that you require a shared_ptr. Can be moved to a new owner, but not copied or shared. Replaces auto_ptr, which is deprecated. Compare to boost::scoped_ptr. unique_ptr is small and efficient; the size is one pointer and it supports rvalue references for fast insertion and retrieval from STL collections. Header file: <memory>. For more information, see How to: Create and Use unique_ptr Instances and unique_ptr Class. shared_ptr Reference-counted smart pointer. Use when you want to assign one raw pointer to multiple owners, for example, when you return a copy of a pointer from a container but want to keep the original. The raw pointer is not deleted until all shared_ptr owners have gone out of scope or have otherwise given up ownership. The size is two pointers; one for the object and one for the shared control block that contains the reference count. Header file: <memory>. For more information, see How to: Create and Use shared_ptr Instances and shared_ptr Class. weak_ptr Special-case smart pointer for use in conjunction with shared_ptr. A weak_ptr provides access to an object that is owned by one or more shared_ptr instances, but does not participate in reference counting. Use when you want to observe an object, but do not require it to remain alive. Required in some cases to break circular references between shared_ptr instances. Header file: <memory>. For more information, see How to: Create and Use weak_ptr Instances and weak_ptr Class.Smart Pointers for COM Objects (Classic Windows Programming): When you work with COM objects, wrap the interface pointers in an appropriate smart pointer type. The Active Template Library (ATL) defines several smart pointers for various purposes. You can also use the _com_ptr_t smart pointer type, which the compiler uses when it creates wrapper classes from .tlb files. It's the best choice when you do not want to include the ATL header files. CComPtr Class Use this unless you cannot use ATL. Performs reference counting by using the AddRef and Release methods. For more information, see How to: Create and Use CComPtr and CComQIPtr Instances. CComQIPtr Class Resembles CComPtr but also provides simplified syntax for calling QueryInterface on COM objects. For more information, see How to: Create and Use CComPtr and CComQIPtr Instances. CComHeapPtr Class Smart pointer to objects that use CoTaskMemFree to free memory. CComGITPtr Class Smart pointer for interfaces that are obtained from the global interface table (GIT). _com_ptr_t Class Resembles CComQIPtr in functionality but does not depend on ATL headers.ATL Smart Pointers for POCO Objects : In addition to smart pointers for COM objects, ATL also defines smart pointers, and collections of smart pointers, for plain old C++ objects. In classic Windows programming, these types are useful alternatives to the STL collections, especially when code portability is not required or when you do not want to mix the programming models of STL and ATL. CAutoPtr Class Smart pointer that enforces unique ownership by transferring ownership on copy. Comparable to the deprecated std::auto_ptr Class. CHeapPtr Class Smart pointer for objects that are allocated by using the C malloc function. CAutoVectorPtr Class Smart pointer for arrays that are allocated by using new[]. CAutoPtrArray Class Class that encapsulates an array of CAutoPtr elements. CAutoPtrList Class Class that encapsulates methods for manipulating a list of CAutoPtr nodes.