The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,226 other subscribers

Archive for February 24th, 2016

Delphi: forward declaration of classes and interfaces, but no records.

Posted by jpluimers on 2016/02/24

As Delphi allows to forward declare both classes and interfaces, people often wonder about records.

The short answer: you can’t forward declare record types.

The long answer: you can’t directly, but you can indirectly either reference based (through pointers or callbacks with const parameters) or operator based (through operator overloading).

I think the reason forward declaration of classes and interfaces is possible because they both are reference types, so referring does not impose copying.

Anyway, the trick is this:

You can’t have forward declarations for record types. Define both Implicit operators in the second type

Source: delphi – How do I define implicit conversion operators for mutually dependent records? – Stack Overflow

–jeroen

via:

Posted in Delphi, Delphi 10 Seattle, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

 
%d bloggers like this: