【UE4 Reflection】Why const member in parent UClass would be private for child UClass ?

MarvinECL
Sat, 11 Feb 2023 11:29:32 +0000
C++

I have two uclasses and an compiler error here:

UCLASS(BlueprintType, Blueprintable)
class UCardCostFuncHolder : public UObject
{
	GENERATED_BODY()

	UCardCostFuncHolder() : CardCostDetails(FCardCost()){};

	UCardCostFuncHolder(const FObjectInitializer& ObjectInitializer) : CardCostDetails(FCardCost()){};

	UCardCostFuncHolder(const FCardCost& CardCost) : CardCostDetails(CardCost){};

public:

	const FCardCost CardCostDetails;
};

UCLASS(BlueprintType)
class UTest_CardCost : public UCardCostFuncHolder
{
	GENERATED_BODY()
};

And now visual studio give me an ERROR:

CardCostLibrary.h(11): error C2248: “UCardCostFuncHolder::UCardCostFuncHolder”: cannot access private member (declared in class “UCardCostFuncHolder”)

And when I check the code at that line, it’s just thie GENERATED_BODY() macro in class UTest_CardCost.

I think this error is related to unreal engine reflection system, and I want to know the solution about this error.

6 posts - 2 participants