Member-Function Dispatch

2018-08-06 ☼ codingc++

class MyClass {
    void start() { }
    void stop()  { }

    void run(int x) {
        auto oper = &MyClass::start;
        if (x == 0) { oper = &MyClass::stop; }
        (this->*oper)();
    }
};