I would like to request that a future release implement these operators and
to ask whether there is a workaround. Can I call a member function of a
class through a pointer in CINT?
The following program runs perfectly under my regular C++ compiler (M'Soft
VC++ 5.0 SP3). However under Root's CINT I get these error messages:
Error: No symbol foo::f in current scope FILE:boo.cpp LINE:56
Error: class,struct,union or type fu.*fn not defined FILE:boo.cpp LINE:47
Error: No symbol foo::g in current scope FILE:boo.cpp LINE:57
Error: class,struct,union or type fu.*fn not defined FILE:boo.cpp LINE:47
//====================== boo.cpp ========================
class foo
{
private:
public:
foo();
~foo();
virtual double f(double x) const;
virtual double g(double x) const;
};
class bar
{
public:
bar();
~bar();
double sqr(const foo& fu, double (foo::*fn)(double) const, double x) const;
};
foo::foo()
{
}
foo::~foo()
{
}
double foo::f(double x) const
{
return x + 1.0;
}
double foo::g(double x) const
{
return 2.0 * x;
}
bar::bar()
{
}
bar::~bar()
{
}
double bar::sqr(const foo& fu, double (foo::*fn)(double) const, double x)
const
{
double y = (fu.*fn)(x); // CINT does not seem to understand the .*
operator here
return y * y;
}
void boo ()
{
bar b;
foo ff;
b.sqr(ff,foo::f,2.0); // CINT does not understand foo::f (ptr to member
function)
b.sqr(ff,foo::g,2.0); // CINT does not understand foo::g
}
//===================================== end of boo.cpp
=================================
===========================================================================
Jonathan M. Gilligan <jonathan.gilligan@vanderbilt.edu>
Research Assistant Professor and Associate Director (615) 343-2957
Center for Molecular and Atomic Studies at Surfaces Fax: 343-1708
Dept. of Physics and Astronomy, Box 1807-B Sec'y 322-6438
Vanderbilt University, Nashville, TN 37235 Lab: 343-7578