I need to pass as parameter to a member function another member function (but from another class). I can do this for functions of the same class, but of another I still can not
#include <iostream>
using namespace std;
void MyP(int a) {
cout << a << endl;
}
class MyPrint {
public:
void MyP(int a) {
cout << a << endl;
}
};
class MyClass {
public:
void MyC(void (*Op)(int)) {
Op(4);
}
};
int main() {
MyPrint A;
MyClass P;
P.MyC(MyP); // Funciona -> Pega a função normal (sem a classe)
P.MyC(A.MyP); // Não Funciona -> Pega a função membro (da classe)
getchar();
return 0;
}
Thanks.