I have a UPROPERTY() variable in a base class called Value which is of an Enumeration Type
Then I create a derived class and create a variable called Value but with a different Enumeration Type.
This is absolutely legal in pure C++, but it seems to be not in Unreal Engine
Member variable declaration: ‘Value’ conflicts with previously defined field in 'BaseClass’
Perhaps, you can look here in the stackoverflow thread, where I asked about same names of the parent class and subclass. I then changes the names, though. Didn’t need the exact matching. First I used this page for analyzing public and private variables (in the scope of a research). I had to compare them then in a table.
Perhaps, you can look here in the stackoverflow thread, where I asked about same names of the parent class and subclass. I then changes the names, though. Didn’t need the exact matching. First I used this page for analyzing public and private variables (in the scope of a research). I had to compare them then in a table.
This sounds like you’re hitting on something related to UPROPERTY only. I’ve had this with static variables - you can’t use UPROPERTY on them.
(But you can then expose them via a static getter, with a UFUNCTION Macro)
I suspect it would be down to the fact that in order for you to access these two variables, you’d need to use fully qualified access and if you’re duplicating the name of a member variable in a derived class, from say a UObject, then that would have implications throughout the engine (as any of the variables that might be accessed, aren’t likely to be done so with fully qualified member access).
As several have commented in this Stack article, it’s not deemed terribly good practice, which I would also wager is why Epic decided not to allow it.
When declaring a variable as UPROPERTY() or a function with UFUNCTION(), the literal name will be stored in look up table. Based my understanding and findings, it has to be unique so UE can somehow find a property by name then guess its type with abstractions and linking it to as BP variable node/function node.
(Please correct me if someone else has more detail knowledge in this, all I know is there is a look up table somewhere that being used for linking)
That is why UE4 doesn’t allow 2 identical names both marked as UPROPERTY() or 2 identical function name both marked as UFUNCTION(). For function, it means overloading UFUNCTION() isn’t possible, but possible if to do certain redirection. I believe such implementation is somewhere.