[fpc-pascal] Access inherited^2

Johann Glaser Johann.Glaser at gmx.at
Sun Aug 10 19:09:15 CEST 2008


Hi!

Am Sonntag, den 10.08.2008, 10:01 +0200 schrieb Vincent Snijders:
> Johann Glaser schreef:
> > Hi!
> > 
> > How can I access an inherited inherited method which was overloaded?
> 
> Try the following, mark the constructors as overloaded:
> > 
> > ====== Example: ======
> > 
> > {$mode objfpc}{$H+}
> > Program TestInherited;
> > Uses Classes, SysUtils;
> > 
> > Type
> >   TFirst = class
>      Constructor Create(A,B,C:Integer); overload;
> >   End;
> >   TSecond = class(TFirst)
>      Constructor Create(A,B:Integer); overload;
> >   End;
> >   TThird = class(TSecond)
>       Constructor Create(A,B:Integer); overload;
> >   End;

Thanks, that really helped now. While Zaher Dirkey's hint (Mon, 4 Aug
2008 15:24:03 +0300) also helped and did it's job, it had one drawback:
If TFirst.Create raised an exception, this could not by caught by
TThird.Create. Even worse, it "converted" to an "Access violation"
exception.

I debugged this issue and found that it happend at a "call 0x30(%ecx)"
instruction in TThird.Create. ECX pointed to a memory structure where
address 0x30 was $00000000. This seems very likely to be a problem with
internals of FPC's handling of constructors and exceptions.

Using "overload" now works like a charm. Michael, could you please add
this to the documentation?

Thanks
  Hansi





More information about the fpc-pascal mailing list