Answer the question
In order to leave comments, you need to log in
How to call an ancestor method in an ancestor method?
There is an abstract class TBase, the class TList is inherited from it. And from TList one more class Т2List is inherited. And here is the question of how to call a method from a TList class method, provided that the methods are overridden in the second class. inherited allows you to call the ancestor method, but if the ancestor method has functions that are defined in the current class, then they are executed, and I need the ancestor to be called
Answer the question
In order to leave comments, you need to log in
As far as I understand there is:
TMyObject = class(TObject)
procedure DoA; virtual;
procedure DoB; virtual;
end;
TMyObject2 = class(TMyObject)
procedure DoA; override;
procedure DoB; override;
end;
...
TMyObject.DoA;
begin
DoB;
end;
TMyObject.DoB;
begin
WrtieLn('MyObject');
end;
TMyObject2.DoA;
begin
inherited DoA; // fix
end;
TMyObject2.DoB;
begin
WriteLn('MyObject2');
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question