I am overriding FChatRoomInfo and it requires to implement the function:
const TSharedRef& GetOwnerId() const = 0;
However I do not know how to return a reference to a shared reference. It keeps failing to compile with the error C4172: returning address of local variable or temporary, even though I am returning a class member variable of type TSharedRef.
It sounds like you’re returning a reference to a temporary variable (like OwnerId.ToSharedRef()), where the return value is not being stored. Because the function returns a reference to the sharedref rather than an instance, you need to make sure the value has a longer lifetime. The easiest way to is have a TSharedRef member variable (not TSharedPtr) on the FChatRoomInfo and just return that.