Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre>#include <iostream>
using namespace std;

typedef void (*PFN)();

class A
{
public:
    void foo()
    {
        run(func);
    }

private:
    void run(PFN pfn1)
    {
        pfn1();
    }

    void func()
    {
        printf("run ");
    }
};

int main()
{
    A a;
    a.foo();

    system("pause");
    return 0;
}





while debuging following error shows:
error C3867: 'A::func': function call missing argument list; use '&A::func' to create a pointer to member
Posted
Updated 1-Oct-10 9:51am
v3
Comments
Aescleal 1-Oct-10 15:52pm    
got rid of the Linux tag - this question is as relevant to Windows, Mobile phones or even embedded systems if they're written in C++

Have a read of this[^].

See if you can't help yourself. :)
 
Share this answer
 
make
void func()
{
    printf("run ");
}

into the follow static member function
// static member Pointer
static void func()
{
    printf("run ");
}


And your syntax should be correct

or for a member function pointer try this

#include <iostream>
// Example Member function pointer
using namespace std;
class A;
typedef void (A::*PFN)();
class A
{
public:
    void foo()
    {
        run(&A::func);
    }
private:
    void run(PFN pfn1)
    {
        ((*this).*pfn1)();
    }
    void func()
    {
        printf("run ");
    }
};
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900