#include #include //for srand, rand, exit, EXIT_SUCCESS #include //for time #include "action.h" using namespace std; int main() { const action menu[] = { //array of objects "cut", "copy", "paste" }; const size_t menu_size = sizeof menu / sizeof menu[0]; //array of pointers to the member functions of the above objects void (action::*const key[])() const = { &action::plain, &action::shifted, &action::controlled }; const size_t key_size = sizeof key / sizeof key[0]; srand(static_cast(time(0))); for (int i = 0; i < 3; ++i) { const size_t m = rand() % menu_size; //which object of class action const size_t k = rand() % key_size; //which member function of class action (menu[m].*key[k])(); //Call member function k of object m. } return EXIT_SUCCESS; }