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

  • Home
  • SEARCH
  • 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 227683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:37:08+00:00 2026-05-11T19:37:08+00:00

I’m trying to build the following block of code in a 1-file .cpp file:

  • 0

I’m trying to build the following block of code in a 1-file .cpp file:

#include <iostream>

#include <algorithm>
using namespace std;

class test
{

public:

    int a[10];
    int index;

    test();
    ~test();
    bool equals(int p);
    void search();
};

test::test()
{
    int temp[10] = {4, 9, 5, 6, 9, 10, 9, 255, 60, 0};

    memcpy(a, temp, sizeof(temp));

    index = -1;
}

bool test::equals(int p)
{
    return p == 9;
}

void test::search()
{
    int* p = std::find_if(a, a+10, &test::equals);
    while (p != a+10)
    {
        cout<< *p;
        index = p - a;
        p = std::find_if(p+1, a+10, &test::equals);
    }
}

int main(int argc, char *argv[])
{
    test object;

    object.search();

    return 0;
}

I am getting an error as shown below, and I’m not sure exactly what’s happening when I use the find_if function in a member method of a class, and I’m getting this error whenever I am doing so.

1>c:\program files\microsoft visual studio 8\vc\include\algorithm(87) : error C2064: term does not evaluate to a function taking 1 arguments
1>        c:\program files\microsoft visual studio 8\vc\include\algorithm(96) : see reference to function template instantiation '_InIt std::_Find_if(_InIt,_InIt,_Pr)' being compiled
1>        with
1>        [
1>            _InIt=int *,
1>            _Pr=bool (__thiscall test::* )(int)
1>        ]
1>        c:\testprogram\nomfc\main.cpp(32) : see reference to function template instantiation '_InIt std::find_if(_InIt,_InIt,_Pr)' being compiled
1>        with
1>        [
1>            _InIt=int *,
1>            _Pr=bool (__thiscall test::* )(int)
1>        ]
  • 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-11T19:37:09+00:00Added an answer on May 11, 2026 at 7:37 pm

    The find_if function expects an object which is callable as a function with no parameters. This is something like a free function, a function object or a static class function. You passed in the address of the equals member function which is none of these. You could resolve this by making the equals function a free function or a static function, since it does not require any members of the test instance.

    // static
    class test
    {
      public:
        static bool equals(int p); // etc
    };
    int* p = std::find_if(a, a+10, &test::equals);
    
    // free
    bool equals(int p)
    {
        return p == 9;
    }
    int* p = std::find_if(a, a+10, equals);
    

    If your real code example requires that it be a member function, then you need to pass in a function object that acts as a closure over the class instance. I favour using the Boost bind method for this, but there are other methods as well.

    int* p = std::find_if(a, a+10, boost::bind(&test::equals, this, _1));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've had to do something similar before and also wasn't… May 12, 2026 at 12:39 am
  • Editorial Team
    Editorial Team added an answer Check out the Screengrab Firefox addon. May 12, 2026 at 12:39 am
  • Editorial Team
    Editorial Team added an answer The first lesson to learn is that when representing currency,… May 12, 2026 at 12:39 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.