RE: TFormula: DefinedVariable()

From: Canal, Philippe (pcanal@fnal.gov)
Date: Thu Aug 05 1999 - 18:33:37 MEST


Hi Gene,

> Anyhow, the behavior I get is:
> If I pass the expression through the TFormula constructor, then the
> Compile()->Analyze()->DefinedVariable() chain seems to call TFormula's
> DefinedVariable() instead of mine. If intead I provide no expression
> in the constructor, but then call Compile() in the code of the derived
> class's constructor, it uses _my_ DefinedVariable(). Lastly, when I
> call the Eval() member function of the class, once again, it calls the
> DefinedValue() of the TFormula base class instead of mine.

This is behavior required by C++.  When functions are called from within
a constructor they can NOT take advantage of virtual function (this is
more or so because at the time the TFormula constructor is executed,
the virtual table for you inheriting class has not been populated with 
the revelent information).  

The only way, in your case to work around this C++ limitation is to call 
Compile() again in the constructor of your class. (by the way this is exactly 
what the TreeFormula constructor does).

Philippe.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:37 MET