How to define a static variable in a C++ class?

I want to define a static float in a C++ class. But the compilation always turns out to be failure. But when I comment out this line, it’s back to normal. (PS. I don’t what to use UPROPERTY to make it exposed to Blueprint.)

In the header, just declare it without assigning a value:

static float PI;

then in cpp file initialize it:

// don't add static keyword here
float UMyBlueprintFunctionLibrary::PI = 3.14;

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