Your code makes me smile: I once tried:
/*
something.cpp Passing a function pointer to a function to do something:
*/
#include <iostream>
bool something() {
std::cout << "\t\"Something in the way she moves...\"\n";
return true;
}
void do_it(bool (*do_something)(void)) {
(*do_something)();
}
bool (*learned)(void);
void learn_anything(bool (*what)(void)) {
learned=what;
}
void do_anything() {
(*learned)();
}
int main() {
std::cout << "something.cpp\n";
std::cout << "\n passing something as argument:\n";
do_it(&something);
std::cout << "\n learning something:\n";
learn_anything(&something);
do_anything();
std::cout << "\n(done)\n";
return 99; // test only ;)
}
Trying the same in a class was more difficult then I expected, though.