[fpc-pascal]Linked List/ pointers/ casting/ OOP Question
Ron Weidner
xecronix at yahoo.com
Sat Jul 10 01:31:08 CEST 2004
> At first glance, this should read
> PwidgetSomething(PCurWidget^.widget)^.meta =
> 'ENTITY'
> because widget is an untyped pointer ?
>
> And the same for the other line ?
>
> Michael.
Thanks Michael. Actually widget is a typed pointer
but the problem I was trying to solve is that widget
could be one of two different types. I think I solved
my problem with the following code, but I will need
write a test program to be sure. It compiles so I
must be getting close. :)
procedure TWidgetContainer.RenderWidgets();
var
entity:PWidgetEntity;
container:PWidgetContainer;
base:PWidget;
begin
MoveFirstWidget();
while (PCurWidget^.next <> nil) do
begin
base:=PCurWidget^.widget; // cast the pointer to a
widget pointer
if (base^.meta = 'ENTITY') then
begin
PCurWidget^.widget:=PCurWidget^.widget;
entity:=PCurWidget^.widget;
entity^.Render();
end
else
begin
container:=PCurWidget^.widget;
container^.Render();
end;
PCurWidget:=PCurWidget^.next;
dispose(PHeadWidget);
PHeadWidget:=PCurWidget;
end;
end;
Ron_W
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
More information about the fpc-pascal
mailing list