TSharedRefobj = MakeShareable(new MyObject()); obj->DoSomething(); obj.Reset();
TSharedPtrIn this example, a new instance of the MyActor class is created using the SpawnActor() method provided by the Unreal Engine. This method returns a TSharedPtr object that points to the newly created actor. The "DoSomething()" method is then called on the actor. Finally, the "Reset()" method is called on the TSharedPtr to remove the reference to the actor and delete it from memory. Package/Library: Unreal Engine C++actor = GetWorld()->SpawnActor (); actor->DoSomething(); actor.Reset();