error C2864: 'UPartiesGameInstance::PartyGameModeString': a static data member with an in-class initializer must have non-volatile const integral type
note: type is 'const FString'
Any ideas what I should do instead?
Also as you might be able to guess, I am not 100% sure when to use const vs. constexpr, but I believe static const and static constexpr is the same in most cases. It would be great if someone would clear that up.
I now put the string in the header file, but outside the class definition:
const FString PartyGameModeString(TEXT("Party"));
UCLASS()
class ROBOTDEFENSECPP_API UPartiesGameInstance : public USessionInterfaceGameInstance
{
...
};
Please let me know if you think if that’s a good solution and a good place to put that string. I am by no means an expert programmer, so I could definitely need some encouragement.
Just to be clear, UE4.16.1 doesn’t support const as a statement or Const as a UFUNCTION specifier. So you hardly can expose your FString in BP (well, through a mutator/getter). And, of course, if you want to make the variable global, don’t forget to add static.