[fpc-pascal] Multiple inheritance is more powerful than Pascal's interfaces ?

Andrey Gusev ag888 at rambler.ru
Fri Jan 25 11:43:30 CET 2008


* Matt Emson <memsom at interalpha.co.uk> [Fri, 25 Jan 2008 10:03:59 
+0000]:
Matt Emson translation,
that is almost the same as in my
attached trial:
---
   TObj = class
    protected
        fff: integer;
    end;

   TObj2 = class(TObj)
   protected
      fff2: integer;
   end;

   TIntf = interface
      procedure ppp;
   end;

    TObji = class(TObj, TIntf)
    public
       procedure ppp; virtual;
	 // AG: virtual only for TObji's
	   // descendants will useful
    end;

    TObj2i = class(TObj2, Tintf)
	//you do not need to use multiple
	  // inheritance here!! TObj2 already
	  // inherits from TObj
	// AG: but TObj2i nowise not bound
	  // to TObji, whereas it needed to
	  // TObji.ppp be "inherited"
    public
       procedure ppp; virtual;
    end;
---

Actually that looks problematic to me:
---
procedure TObj2i.ppp2;
begin
	TObji(TObj(Self)).ppp2;
	// that looks too arbitrary,
	// have object pascal the
	  // same natural solution as
	  // C++'s TObji::ppp() call
end;



More information about the fpc-pascal mailing list