Declaration and Initialization
Shared references are always initialized with a valid object and cannot be declared without being initialized.
Examples of creating new shared pointers:
// Create an empty shared pointer
// Create a shared pointer to a new object
TSharedPtr<FTreeNode> Node( new FTreeNode() );
In the second example, the new FTreeNode object is actually owned by the shared pointer pointing to it. When the shared pointer goes out of scope, the object is destroyed.
When you copy a shared pointer, a reference to the object being pointed to is added.
TSharedPtr<FTreeNode> OtherNodeRef = Node;
The object will persist until no more shared pointers are referencing it.
Shared pointers can be reset using the Reset() method or by assigning null.
Node = null;