Delphi typcast tlist items C++ approach -
Hello I have a question about some type of casting approach. I am translating some Delphi files into C ++. I have a Delphi declaration of class which is taken from TList and it is a base class for other derivative classes. These are the two base classes, Tibajitum and TBS classes. So new classes taken from TBIIlitem and TBEidclass have been announced as TchildItim which has been taken from TBsclass. TChildItem is overwriting some method method and what is more important is that TChildtClass is overriding property items in a way that is now returning TParentItem items with TBCIT installation. With this example, I wanted to show how easy the classes and overriding properties can be made. Receiving the right type of item out of the list is done by calling only the parent (asset) property item and by typing the appropriate type of type, it is Delphi Appurch. I wonder how I can translate this part of this code into C ++. Currently I have declared a new base class which has not been obtained from any class and has public preferences in that and then Using it means that I Want to use Parent Variables such as vector items and type it in a proper way ... My first impression is that I am going in the wrong direction with that delphi viewpoint. What do you suggest? Delphi code is outdated and pre-date genetics, Delphi analog to C ++ templates. In the modern Delphi code, those list sections will not exist. Instead of a In the C ++ code you can only type I also correct your vocabulary Delphi properties can not be overridden. New property in Type TBaseItem = Class (TObject) Public Process Some Processes; Virtual; abstract; End; Type TBaseClass = Class (TList) Private Function GetItem (Index: Integer): TBaseItem; Process settings (value: TBCITIM; index: integer); Public Property Items [Index: Integer]: Read TBCIT Read Write Guest System Setting; End; Function TBaseClass.GetItem (index: integer): TBCITIM; Start the result: = TBCITAM (inherited goods [index]); End; Process TBaseClass.SetItem (value: TBaseItem; index: integer); Inherited items [index]: = value; End;
Type TChildItem = class (TBaseItem) Public Process SomeProcedure; Override; End; Type TChildClass = Class (TBaseClass) Private Function GetItem (Index: Integer): TChildItem; Process SetItem (Value: TChildItem; Index: Integer); Public Property Items [Index: Integer]: TCILEightMaster GetItem Write SetItem; End; TChildClass function .GetItem (index: integer): TChildItem; Start the result: = TBILIT (inherited objects [index]); End; Process TChildClass.SetItem (value: TChildItem; index: integer); Inherited items [index]: = value; End;
class TBaseItem {virtual void SomeMethod (); } Class TBaseClass {public: vector & lt; TBaseItem & gt; item; }; Square TChildItem: Public TBaseItem {} Category TChildClass: Public TBaseClass {};
returns (tciild item) item [idx]
TList & lt; TBaseItem & gt; and
TList & lt; TChildItem & gt; .
vector & lt; TBaseItem * & gt; and
vector & lt; TChildItem * & gt; . There is no point in your C ++ translation to implement
TBaseClass and
TChildClass .
TChildClass is just a new property.
Comments
Post a Comment