Recent

Author Topic: Inheritance of interfaces  (Read 1336 times)

Borneq

  • Full Member
  • ***
  • Posts: 248
Inheritance of interfaces
« on: January 30, 2020, 11:19:09 am »
I have unit1, where is
Code: Pascal  [Select][+][-]
  1.  Intf1 = interface
  2.     methods knows by unit1, for example for Linux and Windows
  3.  end;
  4.  
  5.  TMyClass1 = class(TInterfacdedObject,Intf1)
  6.  
  7.  end;
  8.  

unit2, where is
Code: Pascal  [Select][+][-]
  1.  Intf2 = interface(Intf1)
  2.     methods knows by unit2, for example only for Windows
  3.  end;
  4.  
  5.  TMyClass2 = class(TInterfacdedObject,Intf2)
  6. or better
  7.  TMyClass2 = class(TMyClass1, Intf2)
  8.  end;
  9.  
:-\
It is correct? TMyClass2 has TMyClass1 fields only once?
I prefer TMyClass2 = class(TMyClass1, Intf2) to using TMyClass1 in methods not knowing unit2 and works on TMyClass2/
« Last Edit: January 30, 2020, 11:24:45 am by Borneq »

ASerge

  • Hero Member
  • *****
  • Posts: 2242
Re: Inheritance of interfaces
« Reply #1 on: January 30, 2020, 07:51:46 pm »
Code: Pascal  [Select][+][-]
  1.  TMyClass2 = class(TInterfacdedObject,Intf2)
  2. or better
  3.  TMyClass2 = class(TMyClass1, Intf2)
Better TMyClass2 = class(TMyClass1, Intf2, Intf1)

 

TinyPortal © 2005-2018