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 5941805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:09:43+00:00 2026-05-22T16:09:43+00:00

I have some code where classes inherit from a base class. That base class

  • 0

I have some code where classes inherit from a base class.

That base class has a function which, when run, ought to call functions to be implemented by the children. That is, the general algorithm is the same for all children, but the implementation of the steps should vary.

template<class T>
class Foo
{
    public:
        Foo(T y):y(y) { for(int i; i < 10; ++i) x.push_back(i); };
    protected:
        virtual bool IsOk(T, int)=0;
        void Run()
        {
            vector<int>::iterator it, bound;
            for(int i; i < 10; ++i)
            {
                cout << "step " << i << endl;
                bound = partition(x.begin(), x.end(), bind2nd(mem_fun_ref(&Foo<T>::IsOk), i));
                for (it=x.begin(); it!=bound; ++it)
                    cout << "  " << *it;
            };
        };
    private:
        vector<int>x;
        T y;
};

class Bar : public Foo<int>
{
    public:
        Bar():Foo<int>(50){this->Run();};
        bool IsOk(int x , int y) {return x == y;}

};

However, when I do so, I get the following error message :
no matching function for call to 'mem_fun_ref(bool (Foo<int>::*)(int, int))'

Could anyone provide me with some insight as to what I am doing wong?

  • 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-05-22T16:09:43+00:00Added an answer on May 22, 2026 at 4:09 pm

    Following are the prorotypes for mem_fun_ref

    template <class S, class T>
      mem_fun_ref_t<S,T> mem_fun_ref (S (T::*f)());
    
    template <class S, class T, class A>
      mem_fun1_ref_t<S,T,A> mem_fun_ref (S (T::*f)(A));
    
    template <class S, class T>
      const_mem_fun_ref_t<S,T> mem_fun_ref (S (T::*f)() const);
    
    template <class S, class T, class A>
      const_mem_fun1_ref_t<S,T,A> mem_fun_ref (S (T::*f)(A) const);
    

    Your mem_fun_ref(bool (Foo<int>::*)(int, int)) dosnt match any of these & hence the error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a common base class from which all my ASMX webservice classes will
I have a collection of classes that inherit from an abstract class I created.
I have some code which collects points (consed integers) from a loop which looks
I have some code which is a standalone java application comprising of 30+ classes.
Some background info; LanguageResource is the base class LanguageTranslatorResource and LanguageEditorResource inherit from LanguageResource
I'm using boost singletons (from serialization). For example, there are some classes which inherit
I have built a simple rails app with three classes that inherit from ActiveRecord
I have some code in a javascript file that needs to send queries back
I have some code that gives a user id to a utility that then
I have some code in an IAuthorizationFilter which redirects the user to a login

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.