Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8186045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:03:50+00:00 2026-06-07T02:03:50+00:00

My situation is following, I have two different bisection functions what will be called

  • 0

My situation is following, I have two different bisection functions what will be called at some point in my code. Basically some function calls Bisection2 and this function calls either the passed function or it passes the function pointer to Bisection function.

in header I have

std::vector<double> F();
double F1(double m1, double m2);
double F2(double m1, double m2);
typedef double (MyClass::*MyClassFn)(double,double);
double Bisection(MyClassFn fEval,double min, double max,std::vector<double> args);
bool Bisection2(MyClassFn fEval1,MyClassFn fEval2,double xmin, double xmax, double ymin, double ymax,double *ax, double *ay,std::vector<double> args);

And my bisection functions look like this. I didn’t include all the code because it’s not necessary.

double MyClass::F1(double m1, double m2) {
    m_m1 = m1;
    m_m2 = m2;
    F();
    return m_my;
}

double MyClass::F2(double m1, double m2) {
    m_m1 = m1;
    m_m2 = m2;
    F();
    return m_mx;
}
double MyClass::Bisection(MyClass fEval,double min, double max,std::vector<double> args)
{
    // Setting a lot of stuff here, including auxiliary and leftvalue...

    MyClass *pObj = new MyClass(-1);

    leftvalue = pObj->*fEval(auxiliary, left);
    ightvalue = pObj->*fEval(auxiliary, right);

    // Comparing and setting values here etc.
}
bool MyClass::Bisection2(MyClassFn fEval1,MyClassFn fEval2,double xmin, double xmax, double ymin, double ymax,double *ax, double *ay,std::vector<double> args)
{

    // Setting some values here but these have nothing to do with the problem.
    double yl;
    double leftvalue, rightvalue, middlevalue;

    MyClass *pObj = new MyClass(-1);

    // Setting some values here but these have nothing to do with the problem.
    std::vector <double> arg;
    // pushing some values

    yl = Bisection(fEval2,ymin,ymax,arg); // Here is the first way how I need to pass fEval2 to Bisection function.
    arg.clear();

    if(isnan(yl))
    {
        return M_NAN;
    }
    leftvalue = pObj->fEval1(xl, yl); // And here is the second way how I need to use fEval1.

//.....
}

And then I have basically a function what calls

`Bisection2(F1,F2, m_m2,0.0, 0.0, m_max2, &m_mu1, &m_mu2,args);

The Bisection2(…) call may be incorrect at the moment because I’ve changed the functions a lot since this worked last time. Last time I basically called F1 and F2 function pointers directly inside the functions instead of fEval’s but I’m quite sure it was incorrect way after all even thought it seemed to work somehow.

Now leftvalue = pObj->*fEval(auxiliary, left); causes compiling errors:

error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘fEval (...)’, e.g. ‘(... ->* fEval) (...)’

I’ve tried to see help from here http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2
and also checked maybe different solved problems in these forums but still can’t figure out what I’m doing wrong.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:03:52+00:00Added an answer on June 7, 2026 at 2:03 am

    As the error message says, you need parentheses. This is because the function call has higher precedence than the ->* operator:

    leftvalue = (pObj->*fEval)(auxilary, left);
                ^            ^
    

    Also, you almost certainly shouldn’t be using new here; you can fix the memory leaks using automatic storage:

    MyClass obj(-1);
    leftvalue = (obj.*fEval)(auxiliary, left);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine the following situation: I have two branches: DEV and MAIN. I'm working on
Consider the following situation: We have two Localizable.string files, one in en.lproj and one
Consider the following situation: I have two android projects named P1 and P2 which
I have following Situation, Server A sends some data (HTML form) to server B,
Following situation: I have a JFrame and call JOptionPane.showInputDialog(test) . The modal dialog will
Following situation: I have an array with some constant values, which represent ranges. A
I'm currently working on some performance critical code, and I have a particular situation
I have a situation which I have solved in two different ways, but was
If I have the following situation: Execute() creates a new thread and executes function
Situation I have the following Sitecore Lucene config: New index, type=Sitecore.Search.Index, Sitecore.Kernel Contains two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.