I have a base class with a virtual function:
TMyBaseClass = class(TObject) public ValueOne : integer; procedure MyFunction(AValueOne : integer); virtual; end; procedure TMyBaseClass.MyFunction(AValueOne : integer); begin ValueOne := ValueOne; end;
The descendant class implements a function with the same name. This function adds a new parameter and calls its orchestra function.
TMyDerivedClass = class(TMyBaseClass) public ValueTwo : integer; procedure MyFunction(AValueOne : integer; AValueTwo : integer); end; procedure TMyDerivedClass.MyFunction(AValueOne : integer; AValueTwo : integer); begin inherited MyFunction(AValueOne); ValueTwo := ValueTwo; end;
When compiling, the following warning message is displayed: W1010 Method
"MyFunction" hides the virtual method of the base type "TMyBaseClass"
I found a solution to the problem by reading another question , but I wonder what causes this warning. Does TMyDerivedClass.MyFunction support TMyBaseClass.MyFunction, even if two functions have different parameters? If so, why?
inheritance delphi overrides
Fabrizio
source share