#include <iostream>
using namespace std;
class base_A {
void sum(int a, int b, void (*p)(int)) {
int res = a + b;
(*p)(res);
}
void print(int r) {
cout << "res: " << r;
}
};
int main() {
int x,y;
cout << "Enter two numbers to sum\n";
cin >> x >> y;
void (*p)(int) = base_A::print;
void (*ptr)(int a, int b, void (*p)(int)) = base_A::sum;
(*ptr)(x, y, *p);
return 0;
}
Here how can I access call back functions inside a class member function in C++. Kindly help me on this
Aucun commentaire:
Enregistrer un commentaire