inheritance - Can I create a class that is inherited from a class and from interfaces in Delphi? -


I have class TDevice. Some devices will have a cellular module so I am creating an interface IIMEI other devices will have Ethernet module . So I'll create an interface IMACAdder

Therefore, I would like to create another class which is TDVC's child and implements the IIMI or IMACEdress or both.

Is it possible in Delphi?

The easiest option is to get the TDevice from the Tinterfaced object and extend its lineage with additional methods . Be careful about the interface reference count, however, otherwise you will end up with an unexpected access violation.

Alternatively you can write a cover object that descends from TInterfacedObject and assigns the implementation of the interface to the TDevice lineage. In that case reference count will be less than one problem.

  TMacAddressWrapper = class (TInterfacedObject, IMacAddress) Private FDevice: TDevice; Property Device: ImDacDress Applying TDevice FDevice; Create Public Builders (_Device: TDevice); End; Manufacturer TMacAddressWrapper.Create (_Device: TDevice); Start the heritage; Create; FDevice: = _Device; End;  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -