Why not use TSharedRef directly

Hello, I noticed that in .h file it was declared TSharedPtr instead of TSharedRef. I know it was solved by doing the conversion shown in the video, but why not from the beginning declare as TSharedRef instead? Is there any difference or best practices?

There is a difference between the two. TSharedRef is relating to a reference to another variable whereas TSharedPtr tracks references to the pointer, typically something created and assigned to the variable and when it’s no longer used will be released automatically.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.