delphi - Is it possible to refer to a fields parent class -
using: delphi xe2
a class has field class.
is possible in procedure of field refer container class?
type tclassa = class procedure classamethod; end; type tclassb = class classa : tclassa; end; procedure tclassa.classamethod; begin // possible reference // owning classb object here? end;
no. there no inherent connection between 2 objects. if contained objects needs refer container, contained class needs given reference object. pass in constructor parameter, example:
constructor tclassb.create; begin inherited; classa := tclassa.create(self); end;
if these objects descend tcomponent
, might able use owner
property this.
Comments
Post a Comment