Click here to Skip to main content
15,899,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get the default browser and its's path ? Pin
valikac27-Mar-03 8:30
valikac27-Mar-03 8:30 
AnswerRe: How to get the default browser and its's path ? Pin
vikramj27-Mar-03 18:06
vikramj27-Mar-03 18:06 
GeneralChoose language Pin
Paolo Vernazza27-Mar-03 1:26
Paolo Vernazza27-Mar-03 1:26 
GeneralRe: Choose language Pin
vikramj27-Mar-03 18:11
vikramj27-Mar-03 18:11 
GeneralRe: Choose language Pin
Paolo Vernazza28-Mar-03 3:57
Paolo Vernazza28-Mar-03 3:57 
GeneralPointer to pointers Pin
jyngem27-Mar-03 1:22
jyngem27-Mar-03 1:22 
GeneralRe: Pointer to pointers Pin
HJo27-Mar-03 4:38
HJo27-Mar-03 4:38 
GeneralRe: Pointer to pointers Pin
Iain Clarke, Warrior Programmer27-Mar-03 4:42
Iain Clarke, Warrior Programmer27-Mar-03 4:42 
I presume you want something like:

main ()
{
    BinaryFunction f [] = { {Add, "+"},
                            { Subtract, "-"},
                            { Power, "pow"},
                            { NULL, NULL}
                          };

    double dEval1 = DoAFunctionOne ("Add", 1.0, 2.0, f)
    double dEval2 = DoAFunctionTwo ("Add", 1.0, 2.0, &f)
}

double DoAFunctionOne (char *name, double A, double B, BinaryFunction *func)
{
    while (func && func->sign)
    {
        if (!lstrcmpi (name, func->sign))
        {
            if (!func->eval)
                break;
            return func->eval (A,B);
        }
        func++; // Move on to the next one...
    }

    // Raise an exception?
    return 0.0;
}
double DoAFunctionTwo (char *name, double A, double B, BinaryFunction **func)
{
    for (int n = 0; func && func [n]->sign; n++)
    {
        if (!lstrcmpi (name, func->sign))
        {
            if (!func [n]->eval)
                break;
            return func [n]->eval (A,B);
        }
    }

    // Raise an exception?
    return 0.0;
}


Having typed this all, I've got a sneaking suspicion I've just done your homework. If I'm right,
take this as an example of how these things work. If you hand it in as your own work then your
teacher will become suspicious...

If I'm wrong, then I apologise!

Iain.
GeneralBig prime numbers Pin
Jump_Around27-Mar-03 1:19
Jump_Around27-Mar-03 1:19 
GeneralRe: Big prime numbers Pin
Alastair Taylor27-Mar-03 1:49
Alastair Taylor27-Mar-03 1:49 
GeneralOwnerdraw menus and SetWindowsHookEx Pin
_Theo_27-Mar-03 0:49
_Theo_27-Mar-03 0:49 
GenerallParam member of HDITEM structure Pin
JensB27-Mar-03 0:06
JensB27-Mar-03 0:06 
GeneralRe: lParam member of HDITEM structure Pin
Remon Spekreijse27-Mar-03 0:15
Remon Spekreijse27-Mar-03 0:15 
GeneralRe: lParam member of HDITEM structure Pin
JensB27-Mar-03 1:48
JensB27-Mar-03 1:48 
GeneralRe: lParam member of HDITEM structure Pin
Remon Spekreijse27-Mar-03 2:43
Remon Spekreijse27-Mar-03 2:43 
GeneralRe: lParam member of HDITEM structure Pin
Michael Dunn27-Mar-03 3:41
sitebuilderMichael Dunn27-Mar-03 3:41 
GeneralADO & ADOX Pin
rosen26-Mar-03 22:26
rosen26-Mar-03 22:26 
GeneralRe: ADO & ADOX Pin
RChin27-Mar-03 0:09
RChin27-Mar-03 0:09 
GeneralRe: ADO & ADOX Pin
Rickard Andersson2027-Mar-03 0:11
Rickard Andersson2027-Mar-03 0:11 
GeneralRe: ADO & ADOX Pin
rosen27-Mar-03 8:22
rosen27-Mar-03 8:22 
GeneralString sorting using STL Pin
Chintan26-Mar-03 21:25
Chintan26-Mar-03 21:25 
GeneralRe: String sorting using STL Pin
Mike Nordell26-Mar-03 22:09
Mike Nordell26-Mar-03 22:09 
Generaldiff style source code Pin
Colin Davidson26-Mar-03 21:23
Colin Davidson26-Mar-03 21:23 
GeneralRe: diff style source code Pin
Neville Franks26-Mar-03 22:20
Neville Franks26-Mar-03 22:20 
GeneralRe: diff style source code Pin
Pavel Klocek27-Mar-03 1:00
Pavel Klocek27-Mar-03 1:00 

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.