Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-03

Forward definitions of nested classes in outer scope

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jonas Maebe

Hello,

Could someone check whether or not this compiles with Delphi 2009+ ?

****
type
  tforward = class;
  tc = class
   type
    tnest = class
    end;
  end;
  ty = class
    function f: tforward;
  end;
  tforward = tc.tnest;
begin
end.
***

Thanks,

Jonas

Reply by email

Willibald Krenn
to Jonas Maebe
Jonas Maebe wrote
Hello, Could someone check whether or not this compiles with Delphi 2009+ ?

No, this does not compile on XE. However, you can do this:

   tforward = class;
   tc = class
    type
     tnest = class
     end;
   end;
   ty = class
     function f: tforward;
   end;
// let tforward be a class derived from tc.tnest
   tforward = class (tc.tnest);
You can also do this, of course:
   tc = class
    type
     tnest = class
     end;
   end;
   tforward = tc.tnest;
   ty = class
     function f: tforward;
   end;

Cheers,
Willibald

Reply by email