From Marcel Schepers · 1996-04-09 02:02 · #73658 in EMULATE
Hello,
I am faced with a typical C++ problem. I wrote a DLL (I am working in MS-Windows) with a function which is declared as:
void FAR PASCAL _export bs(float y[], int nv, void (*derivs)(float, float *, float *));
The DLL consists of no OOP techniques. It is merely a collection of good working C code. In my main window class, a child of TWindow (Borland OWL 1.0), I declared the following public function:
virtual void TBlackHoleWindow::Derives(float Sigma, float X[], float dXdS[]);
The purpose of this function is that it will be the last parameter when I make a call to the bs( ...) function. I want to call to the bs( ... ) function in a descendant TApplication::IdleAction() function.
When working in a non OO mode this will look like: bs(pfX, NV, Derivs). The pfX variable is a pointer to a array of floats with lenght NV, NV is the dimension and Derivs is the address of the function, which will be called by bs( ... ).
In OO mode I have to make sure that I access the correct values, so some converting is needed. How can I do that? I have tried several different syntax combinations. None of them worked. I will give you a list of them, with the compiler error output. (I use Borland C/C++ 3.1 with OWL 1.0)
Here are some _not_ working function calls:
bs( ((TBlackHoleOrbitsWindow *)MainWindow)->pfX,
NV,
&TBlackHoleOrbitsWindow::Derivs);
The error output is: Compiling SOURCE\BHORBITS.CPP:
Error SOURCE\BHORBITS.CPP 70: Cannot convert 'void(TBlackHoleOrbitsWindow::*)(float,float *,float *)' to 'void (*)(float,float *,float *)'
bs( ((TBlackHoleOrbitsWindow *)MainWindow)->pfX,
NV,
((TBlackHoleOrbitsWindow *)MainWindow)->Derivs);
Error output: Compiling SOURCE\BHORBITS.CPP:
Error SOURCE\BHORBITS.CPP 70: Member function must be called or its address taken
And I can live with these, as long as it is possible to make a appropiate convertion. I can't figure out how to accomplish that. Any ideas?
Marcel
(m.schepers@tess.nl)
--- MBM v3.30d
* Origin: MBM v3.31 Turbo Vision (2:2802/100.2038)