If I have a class which has a method which takes a second class as an parameter. And then I have third class which is inherited from second, so it contains same methods as second one does. Now if I want to pass that third class to the method of the first class. How to implement that method so it accepts a class and all it's descendants?
for example...
How to implement something like that?Code:TFirstClass = Class private public procedure Dosomething(AClass: ???????); // How to do this so it accepts end; //the second and all its descentand classes? TSecondClass = Class private public procedure DoSomething; end; TThirdClass = Class(TSecondClass) // Notice inheritance. private public procedure DoSomethingElse; end; var FirstClass: TFirstClass; 3rdClass: TThirdClass; . . . procedure SomeProcedureSomewhere; begin FirstClass.DoSomething(3rdClass); end;
Bookmarks