I noticed that creating a function with the same name than an Ufunction of the base class, even with different signatures, confuses the compiler a lot.
As an example, the Primitive Component declares the following Ufunction:
virtual void SetMaterial(int32 ElementIndex, class UMaterialInterface* Material);
Inheriting from it, I declare a function with the same name but different signature:
class UFooMeshComponent : public UPrimitiveComponent
void SetMaterial( UMaterial* InMaterial );
I get the following compiler warnings:
FooMeshComponent.h(12): warning C4263: 'void UFooMeshComponent::SetMaterial(UMaterial *)' : member function does not override any base class virtual member function
FooMeshComponent.h(13): warning C4264: 'void UPrimitiveComponent::SetMaterial(int32,UMaterialInterface *)' : no override available for virtual member function from base 'UPrimitiveComponent'; function is hidden
Engine\Source\Runtime\Engine\Classes\Components/PrimitiveComponent.h(624) : see declaration of 'UPrimitiveComponent::SetMaterial'
Engine\Source\Runtime\Engine\Classes\Components/PrimitiveComponent.h(102) : see declaration of 'UPrimitiveComponent'
So different things confuse me here:
I know this is a poor choice of names anyway but why is that an issue at all to the compiler since the signatures are different? I'm not using "override" here. Is the compiler being somehow too smart? Or is it something with the additional code generated by UHT?
Could UHT catch this sort of mistakes earlier on, as it does with implementations of overridden interface functions?
Mar 18 '15 at 10:21 AM
in C++ Programming