[fpc-pascal] Case in Record

Henry Vermaak henry.vermaak at gmail.com
Tue Oct 6 15:56:01 CEST 2009


2009/10/6 章宏九 <secludedsage at gmail.com>:
> In the document
> (http://www.freepascal.org/docs-html/ref/refsu15.html#x38-450003.3.2)
> I read the code below:
>
> Type
>  MyRec = Record
>          X : Longint;
>          Case byte of
>            2 : (Y : Longint;
>                 case byte of
>                 3 : (Z : Longint);
>                 );
>          end;
>
> I still cannot understand what do these two "byte" mean. I have
> difficulty in understanding "The optional identifier in the case
> statement serves to access the tag field value, which otherwise would
> be invisible to the programmer" and need some explain. Thank you.

Look at the second example on this page:

http://delphibasics.co.uk/RTL.asp?Name=Record

>
> Another problem is about Object and Class. I notice that in wiki
> (http://wiki.freepascal.org/Object_Oriented_Programming_with_FreePascal_and_Lazarus),
> Class is explained as a pointer to the structure, while Object returns
> the whole structure. And the wiki said that Object is not used very
> much. Does this mean that Object is deprecated? Can Objects contain
> any properties?

Look at this page for an explanation of the basic difference:

http://freepascal.org/docs-html/ref/refch6.html

I can't really comment on the scary details, since I'm rubbish at
object oriented programming :)

Henry



More information about the fpc-pascal mailing list