// Create a new shared string object TSharedRef< FString > MySharedString = MakeShared< FString >(TEXT("Hello World")); // Access the string value and print it to the console UE_LOG(LogTemp, Warning, TEXT("MySharedString contains \"%s\""), *MySharedString->ToString());
// Create an array of shared integer objects TArray< TSharedRef< int32 > > SharedInts; // Add some integer values to the array SharedInts.Add(MakeShared< int32 >(10)); SharedInts.Add(MakeShared< int32 >(20)); SharedInts.Add(MakeShared< int32 >(30)); // Loop through the array and print each integer value to the console for (const TSharedRef< int32 >& SharedInt : SharedInts) { UE_LOG(LogTemp, Warning, TEXT("SharedInt contains %d"), *SharedInt); }This example creates an array of shared integer objects and adds three integer values to it using the MakeShared function. It then loops through the array and prints each integer value to the console using UE_LOG. Package Library: Unreal Engine