> Is it possible ?
> 
> In details:
> 
> Suppose:
> 
> program Test;
> 
> type
>   TClassA = class;
>   TClassB = class(TClassA);
>   TClassC = class(TClassA);
> 
> 
>   procedure P( x: TClassA);
> 
>   begin
>     ...
>   end;
> 
> begin
>   P(TClassB.Create)
> end.
> 
> If I watch x inside P in the IDE, i see it is of type TClassA.
> 
> But I want to know it's runtime type, that is if it is TClassB or TClassC.

Do you want to see it in the debugger? Then you need to try to examine
tobject properties or methods (like Anton said).

If you want to know it in a program, use the IS operator.

program Test;

type
  TClassA = class       
            end;
  TClassB = class(TClassA);
  TClassC = class(TClassA);



  procedure P( x: TClassA);

  begin
    if x IS TClassB then
     writeln('TClassB');
    if x IS TClassA then
     writeln('TClassA');
    if x IS TClassC then
     writeln('TClassC');
  end;

begin
  P(TClassB.Create)
end.

will print class B AND A (because it is also a TClassA)
_______________________________________________
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to