> From: "Sean ROBINS" <[EMAIL PROTECTED]>
> Subject: Declaration of types/constants within the class interface
> To: <[email protected]>
> Message-ID:
> <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="us-ascii"
>
>
> It seems that since Delphi2005 was released, you can declare constants
> and types within the body of a class's interface declaration.
>
> For example:
>
> unit MyUnit;
>
> interface
>
> type
> TMyClass = class(TObject)
> public
> const
> A_LITTLE_CONSTANT = 5;
> type
> TMyInternalEnum = (aFirstItem, aSecondItem, aThirdItem);
>
> ....
>
> end;
>
> implementation
>
> ...
>
> end;
>
>
>
> The question is, why would you want to use this style of declaration,
> and what are the benefits/pitfalls of doing so?
>
>
>
> Cheers,
>
> S.
>
> Sean Robins
> Senior Programmer
> Dynamic Hearing Pty Ltd
>
Sean,
You could always do this - it is encapsulation.
It allows an object to declare its types in public for other objects to use.
You might do something like
Type
TBookings = class( TMyBaseObject)
const
TBookingStatus = [bsUnbooked, bsBooked, bsDispatched, bsPickedUp,
bsDelivered, bsError];
TBookingString : array [bsUnbooked .. bsError] : string[10] =
('Unbooked', and so on
Mick
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi