I’m absolutely new to UE4 and C++. My background is Perl but I was talked into helping with some game programming.
This is the pertinent section of code in the cpp file.
in the *.cpp file
static ConstructorHelpers::FObjectFinder<UDataTable> StarNameTableObject(TEXT("DataTable'/Game/Data/Core/DataTables/starnames.StarNames'"));
if (StarNameTableObject.Succeeded()) {
StarNameTable = StarNameTableObject.Object;
if (StarNameTable != nullptr)
{
TArray<FStarNames*> GetList;
StarNameTable->GetAllRows<FStarNames>(TEXT("Starname retrieval failed"), GetList);
int Count = GetList.Num();
UE_LOG(LogTemp, Warning, TEXT("My Star Names Imported %d"), Count);
** FString MyName = GetList[0];
UE_LOG(LogTemp, Warning, TEXT("My First Name Imported %s"), MyName);**
}
else { UE_LOG(LogTemp, Warning, TEXT("Star Names NOT Imported")); }
}
The red section is what I’m currently having issues with and I know it has to do with using a point in defining the TArray (FStarNames*). The VS compiler says:
'Error C2440 ‘initializing’: cannot convert from ‘FStarNames *’ to ‘FString’
In the *.h file the TArray is declared like this:
UCLASS()
class MYCLASS_API AGalaxySpawner : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AGalaxySpawner();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(EditAnywhere)
UDataTable* StarNameTable;
TArray<FStarNames*> MyStarName;
};
Now, when I comment out the red marked code, it compiles and runs. So I’m obviously missing something about using pointers especially in this context.