Thank you for your reply. However, it's not exactly what I was looking for. I don't think I was clear enough in my question, so here's a simple example :
class Button {
public :
Button(etc, etc, etc, void (*action)());
void onPressed() { *action(); }
};
void randomAction() {
// Some code
}
int main() {
ObjectA A;
ObjectA AA;
ObjectB B;
ObjectC C;
Button b(etc, etc, etc, &A.action); // isn't allowed by C++ ISO
Button b(etc, etc, etc, &B.action); // isn't allowed by C++ ISO
Button b(etc, etc, etc, &randomAction); // is allowed by C++ ISO
// Other code
return 0;
}
So what I want to do, is execute an action ON ANY KIND OF
SPECIFIC OBJECT i want, when the button is pressed. Which is not allowed by the C++ ISO, which says :
Quote:
|
error : ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say ‘&ObjectA::action’
|
But saying "&ObjectA::action" WILL NOT alter the specific object ("A" in this case), it will only call ObjectA::action(), not A.action().
Hope you guys understand better now
Any suggestions?