Problem

Hello

I had slow compile times, so I used the code from an other student to make it compile faster.
This code:

TArray<FString> WordList;
    const FString WordListPath = FPaths::ProjectContentDir() / TEXT("HiddenWordList.txt");
    FFileHelper::LoadFileToStringArray(WordList, *WordListPath);

But I have a problem with this lecture, because the code above is not global (the scope is BeginPlay()), so I cant use the variable WordList in the SetupGame() function.
Then I tried to make WordList global, but it failed:

C:\Users\MyUserName\Documents\repos\BullCowGame\BullCowGame-starter-kit\Source\BullCowGame\BullCowCartridge.cpp(8) : error C2761: 'bool FFileHelper::LoadFileToStringArray(TArray<FString,FDefaultAllocator> &,const TCHAR *,FFileHelper::EHashOptions)': redeclaration of member is not allowed

Why cant I do this?
Thanks in advance

Would need to see your code to see where you went wrong.
However that code was given for a later lecture where the isograms are stored as a member variable. With this lecture you just need to remove WordList from the above code and make it a member variable.

I may just confirm that declaring the variable as a member var in the header file is not only the solution but the one that was actually mentioned in the 69th piece of the lecture as suggested move.

Had a similar issue with this. Besides declaring it as a member var in the header file, be sure to execute the code you provided before calling SetupGame(); Otherwise it crashes Unreal as it appears to be trying to access a TArray that hasn’t been set yet.

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

Privacy & Terms