Ask Function problem?thanks
<<<<<<<<<<Class.h>>>>>>>>>>

#pragma once
class Class
{
public:
    int get_return(int a,int b,int (*compare)());
    int Rxgmoral(int a,int b);
    void Fun();
};

<<<<<<<<<Class.Cpp>>>>>>>>

#include "Stdafx.h"
#include "Class.h"
int Class::get_return(int a,int b,int(* compare)())
{
    return (compare(a,b));
}
int Class::Rxgmoral(int a, int b)
{
    return a+b;
}
void Class::Fun()
{
    int a;
    a=get_return(1,2,&Rxgmoral);
}
error:
e:\mystudio\project\test\test\class.cpp(6) : error C2197: 'int (__cdecl *)(void)' : too many arguments for call
e:\mystudio\project\test\test\class.cpp(17) : error C2276: '&' : illegal operation on bound member function expression

thanks:)

try this
<<<<<<<<<<Class.h>>>>>>>>>>

#pragma once
class Class
{
public:
    int get_return(int a,int b,int (*compare)(int, int));
    int Rxgmoral(int a,int b);
    void Fun();
};

<<<<<<<<<Class.Cpp>>>>>>>>

#include "Stdafx.h"
#include "Class.h"
int Class::get_return(int a,int b,int(* compare)(int, int))
{
    return (compare(a,b));
}
int Class::Rxgmoral(int a, int b)
{
    return a+b;
}
void Class::Fun()
{
    int a;
    a=get_return(1,2,Rxgmoral);
}

Missed another one. You can't call non-static member functions like that. So change it to static.
<<<<<<<<<<Class.h>>>>>>>>>>

#pragma once
class Class
{
public:
    int get_return(int a,int b,int (*compare)(int, int));
    static int Rxgmoral(int a,int b);
    void Fun();
};

<<<<<<<<<Class.Cpp>>>>>>>>

#include "Stdafx.h"
#include "Class.h"
int Class::get_return(int a,int b,int(* compare)(int, int))
{
    return (compare(a,b));
}
int Class::Rxgmoral(int a, int b)
{
    return a+b;
}
void Class::Fun()
{
    int a;
    a=get_return(1,2,Class::Rxgmoral);
}

thank you help:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.