Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Dependency Walker lists a DLL as missing. However, program works without Error. Why? Pin
Tim Smith12-Apr-04 6:26
Tim Smith12-Apr-04 6:26 
GeneralNewbie GDI question Pin
Indrawati12-Apr-04 2:21
Indrawati12-Apr-04 2:21 
GeneralRe: Newbie GDI question Pin
David Crow12-Apr-04 3:53
David Crow12-Apr-04 3:53 
GeneralFile reading Pin
perozbabu12-Apr-04 2:10
perozbabu12-Apr-04 2:10 
GeneralRe: File reading Pin
David Crow12-Apr-04 3:58
David Crow12-Apr-04 3:58 
GeneralForm Width/Height & Pointer problem Pin
uus9912-Apr-04 2:02
uus9912-Apr-04 2:02 
GeneralCompiler Error Pin
Kash12-Apr-04 1:58
Kash12-Apr-04 1:58 
GeneralRe: Compiler Error Pin
Nitzan Shaked12-Apr-04 2:47
Nitzan Shaked12-Apr-04 2:47 
Yes. You are trying to send a MEMBER FUNCTION as a "regular" (global-scope) function to CWork::DriverFunc().

You can't send pointers to member functions as "regularly" as you send pointers to "regular" functions. The discussion on this is long, and you would have no problems finding the reasons on the web. It's too long to be included here.

In any case, you have three basic options:

1) If you don't care that DriverFunc() will get a CWork-method (rather than "any" function returning double and accepting a double-array), you can change it's prototype to:

typedef double (*CWork::dblfunc)(double[]);

double CWork::DriverFunc( dblfunc func, double start[] )
{
...
}

2) Instead of passing "Equation" to DriverFunc, pass an intermediate function which will call Equation. This function will be a static member of CWork, so even if Equation() is "hidden" it will still be able to call it. This also means you'll have to pass "this". Here's how it goes:

static CWork::CallEquation( CWork* That, RestOfParamsForEquation )
{
That->Equation( RestOfParamsForEquation );
}

and then:

typedef double (*WrapperForEquation)( CWork* That, RestOfParamsForEquation );

CWork::DriverFunc( WrapperForEquation w, double start[] )
{
...
( Whever you want to call the passed function, use w(this,ParamsYouWouldLikeToPass) )
}

And then in WorkIt(), call DriverFunc with CallEquation() as the first argument

3) The third option is THE ugliest by far, slightly more complex, but does EXACTLY what you want. It will only work if Equation() satisfies a list of requirements (non-virtual, non-static), is NOT portable, and like I said: ugly. But it actual usage it's the simplest, and I like it...

The idea is basically to circumnavigate the compiler's type checking system (which is what yells at you in the first place), which WILL allow you get the address of CWork::Equation. You would have to use the value with care, but it can be done. I'll elaborate more if you want, but like I said: it's ugly...

Good luck.

-- Calius
GeneralRe: Compiler Error Pin
Kash12-Apr-04 3:24
Kash12-Apr-04 3:24 
GeneralRe: Compiler Error Pin
Nitzan Shaked12-Apr-04 7:05
Nitzan Shaked12-Apr-04 7:05 
GeneralRe: Compiler Error Pin
Kash13-Apr-04 23:05
Kash13-Apr-04 23:05 
GeneralSplitters! Message Box Pin
ZoomBoy2712-Apr-04 1:49
ZoomBoy2712-Apr-04 1:49 
GeneralRe: Splitters! Message Box Pin
ZoomBoy2712-Apr-04 2:00
ZoomBoy2712-Apr-04 2:00 
QuestionHard Drive, BIOS and CPU serial number in VC++ 6.0? Pin
Freddie Code12-Apr-04 1:15
Freddie Code12-Apr-04 1:15 
AnswerRe: Hard Drive, BIOS and CPU serial number in VC++ 6.0? Pin
Milton Karimbekallil12-Apr-04 1:57
Milton Karimbekallil12-Apr-04 1:57 
AnswerRe: Hard Drive, BIOS and CPU serial number in VC++ 6.0? Pin
David Crow12-Apr-04 4:12
David Crow12-Apr-04 4:12 
AnswerRe: Hard Drive, BIOS and CPU serial number in VC++ 6.0? Pin
Darshan Jani12-Apr-04 7:47
Darshan Jani12-Apr-04 7:47 
GeneralTrouble with _variant_t Pin
yanuart12-Apr-04 1:08
yanuart12-Apr-04 1:08 
GeneralRe: Trouble with _variant_t Pin
Milton Karimbekallil12-Apr-04 1:48
Milton Karimbekallil12-Apr-04 1:48 
QuestionAre there somewhere good articles about MTS ? Pin
vgrigor12-Apr-04 0:53
vgrigor12-Apr-04 0:53 
Generalunsigned chars Pin
packetlos12-Apr-04 0:10
packetlos12-Apr-04 0:10 
GeneralRe: unsigned chars Pin
John R. Shaw12-Apr-04 0:37
John R. Shaw12-Apr-04 0:37 
GeneralRe: unsigned chars Pin
packetlos12-Apr-04 1:21
packetlos12-Apr-04 1:21 
GeneralRe: unsigned chars Pin
packetlos12-Apr-04 5:38
packetlos12-Apr-04 5:38 
Generaldouble and float variables Pin
deniz79s12-Apr-04 0:04
deniz79s12-Apr-04 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.