Constructor inheritance problem

I have two classes: base class and derived class. My base class has a constructor for this form:

constructor TBaseClass.CreateFromXML(ANode: IXMLNode);
begin

  Create;

  //Set members from XML

end;

My derived class has a constructor of this kind:

constructor TDerivedClass.Create;
begin

   FDatabaseID = -1;

end;

My problem is that when I create an object of my derived class using the constructor from the base class [ TDerivedClass.CreateFromXML(Node);], the Create created at the beginning of the CreateFromXML constructor is not the one from my derived class, one of which is inherited from my base class from TObject.

Is it possible for the constructor of the base class to invoke the constructor of the derived class, even if it further “omits” the inheritance chain?

+3
source share
1 answer

constructor Create; virtual; TBaseClass. "" override.

+8

Source: https://habr.com/ru/post/1757993/


All Articles