mercredi 24 août 2016

C++ - pass a function for an object [duplicate]

This question already has an answer here:

I'm trying to do something to this effect in C++:

class A {
  int get_something();
  int get_something_else();
}

int AccessA(A a, <fn-ptr>) {
    return a.<fn-ptr>
}

Basically, I want to pass the function I would like to call on a given object.

Is there a way I can do this in C++?

Thanks, Azeem

Aucun commentaire:

Enregistrer un commentaire