A few simple C++ questions

William J. Deninger (deninger@uiuc.edu)
Sun, 21 Dec 1997 00:51:19 -0600


Hello again from tropical Illinois,

I have two (basic) C++ questions I would like to present to any Guru in ROOT
land.

(1): How might I pass a public member function of class MYCLASS into the
constructor TF2?

class MYCLASS
{
Double_t MYCLASS::myfunction(Double_t *x, Double_t *y) { return
x[0]*X[1]; };
};

MYCLASS myclass;
TF2 *tf2 = new TF2("name", ???myclass.myfunction???, 0, 1, 0, 1); // this
doesn't work of course. Is there a way?

(2): Is there a method in C++ to obtain member function resolution by return
type? For example

Double_t VECTOR::operator*(const VECTOR& rhs); // inner product
VECTOR operator*(const VECTOR& rhs); // cross product
MATRIX operator*(const VECTOR& rhs); // outer product

Double_t result;
VECTOR v1, v2;
result = v2*v2; // this should use correct function based on return
assignment.

Eagerly waiting for Christmas and thesis.
William Deninger
deninger@uiuc.edu