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

Ewald ewald at yellowcouch.org
Sat Aug 23 13:11:24 CEST 2014


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;


-- 
Ewald




More information about the fpc-devel mailing list