Back again :-)

A question I've been meaning to post for a while,

I have a controller class which owns a collection of an abstract classes
children.  There was some similarity between children to warrant placing
into the parent class but the children have a few different properties and
methods.  In the controller class, I have a property called LastElement
which returns one of those children via the abstract interface.  Currently I
am casting based on the fact I know what the last element was

eg

with ControllerClass do begin
        ControllerClass.AddElement(TSpecificChild.Create);
        with TSpecificChild(LastElement) do begin
                // Do Stuff
        end;
end;

Is there some way of doing this without that cast? (or an is / as paring)
It works fine as is but I would quite like to remove the casting.  Should I
provide the method in the abstract class, override in the child class to
return itself?

Thanks in advance

Tony Sinclair
Holliday Group Limited
Christchurch
New Zealand

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to