[fpc-devel] Newbie question: how does the compiler know the class type of an object ( the Is operator)

Dennis Poon dennis at avidsoft.com.hk
Sat Aug 23 18:17:50 CEST 2014



Ewald wrote:
> On 08/23/2014 11:34 AM, Dennis Poon wrote:
>>         8.2.13 Class types
>>         <http://www.freepascal.org/docs-html/prog/prog.html#QQ2-212-239>
>>
>> Just like objects, classes are stored....
>>
>> Look like it is referring to a TClass instance instead of an TObject
>> instance but thanks  a lot for pointing me into the right direction. \
> No, it is referring to the difference between
>      Type
>          TA = Object
>          End;
>
> and
>      Type
>          TB = Class
>          End;
>
>
> If you type
>
>      Var
>             A: TA;
>             B: TB;
>      Begin
>      End;
>
> Then TA is allocated on the stack, whereas TB will be allocated on the
> heap once you call TB.Create;
>
>
Oh I see now. The old "object" style used in turbo pascal!

Dennis



More information about the fpc-devel mailing list