Re: [ROOT] Checking inheritance

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Nov 01 2001 - 11:14:45 MET


Hi Anton,

This functionality has always been in ROOT. Do:
 TClass *cl1 = TMyClass::Class();
 TClass *cl2 = TMyOtherClass::Class();
 if (cl1->InheritsFrom(cl2)...
you can also do
 if (cl1->InheritsFrom("TMyOtherClass");

See TClass

In the interpreter, you can also do:
 TClass *cl1 = gROOT->GetClass("TMyClass");

Rene Brun


Anton Fokin wrote:
> 
> Hi people,
> 
> I would like to do something like
> 
>   ::InheritsFrom("TMyClass", "TMyAnotherClass");
> 
> which as you see checks if TMyClass inherits from TMyAnother class and
> takes class names as arguments.
> 
> Is it possible? If not, I think it would be a useful RTTI CINT
> extension.
> 
> Cheers,
> Anton



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:05 MET