Skip to content

Interfaces and multiple inheritance

As always the whole project folder is ready, here.

And know the code of the two interfaces:

unit Human;

{$mode objfpc}{$H+}

interface

uses
  Classes,SysUtils,Dialogs;

type
  IHuman = Interface //Human is an INTERFACE
  //Interface has no visibility speciļ¬ers (public private protected). All members are public !!!
  //Interface has no attributes!!!
  //Inteface has only not implemented (virtual abstract) methods that must be redefined by the children...
  function GetSex():string;
  procedure SetSex(Sex_:string);

  end;

implementation
 //An interface has NO implementation !!!

end.

---------------------------------------------------------------------------

unit Social;

{$mode objfpc}{$H+}

interface

uses
  Classes,SysUtils,Dialogs;

type
  ISocial = Interface //Social is an INTERFACE
  //Interface has no visibility modifiers (public private protected). All members are public !!!
  //Interface has no attributes!!!
  //Interface has only not implemented (virtual abstract) methods that must be redefined by the children...
  function GetCharacter():string;
  procedure SetCharacter(Character_:string);

end;

implementation
//An interface has NO implementation !!!

end.

That's all for now!

Hope this will increase your curiosity to try and modify our code, or to write a new one from scratch.

As always the key to start is fun: more serious states of mind will come as long as you'll keep on designing and coding.

See you on next article!