Is it always safe to typecast a old style object as its parent?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Is it always safe to typecast a old style object as its parent?

Dennis


TParent = object
    A : integer;
end;

TChild=object(TParent)
    B : integer;
end;


var
    Parent : TParent;
    Child : TChild;


  begin

     Child.A := 10;
     Child.B := 20;

     Parent := TParent(Child );//  is this always safe ? Will it copy
ONLY the 'A'  field to 'parent'?  Will it overwrite some memory space
beyond the legitimate boundary of 'parent'?

end.


Thanks a lot in advance.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Loading...