#include <iostream>
using namespace std;
class Container;
class F
{
public:
typedef void (Container::*FuncPtr)();
F(Container &c, FuncPtr fp) : m_c(c), m_fp(fp) {}
void Execute() { (m_c.*m_fp)(); }
private:
Container& m_c;
FuncPtr m_fp;
};
class Container
{
public:
Container() : fps(*this, &Container::Func) { }
void Func() { cout << "hello from Container::Func()" << endl; }
void Execute() { fps.Execute(); }
private:
F fps;
};
int main() {
Container c;
c.Execute();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQ29udGFpbmVyOwoKY2xhc3MgRgp7CnB1YmxpYzoKICAgIHR5cGVkZWYgdm9pZCAoQ29udGFpbmVyOjoqRnVuY1B0cikoKTsKICAgIAogICAgRihDb250YWluZXIgJmMsIEZ1bmNQdHIgZnApIDogbV9jKGMpLCBtX2ZwKGZwKSB7fQogICAgdm9pZCBFeGVjdXRlKCkgeyAobV9jLiptX2ZwKSgpOyB9CnByaXZhdGU6CiAgICBDb250YWluZXImIG1fYzsKICAgIEZ1bmNQdHIgbV9mcDsKfTsKCmNsYXNzIENvbnRhaW5lcgp7CnB1YmxpYzoKICAgIENvbnRhaW5lcigpIDogZnBzKCp0aGlzLCAmQ29udGFpbmVyOjpGdW5jKSB7IH0KICAgIHZvaWQgRnVuYygpIHsgY291dCA8PCAiaGVsbG8gZnJvbSBDb250YWluZXI6OkZ1bmMoKSIgPDwgZW5kbDsgfQogICAgdm9pZCBFeGVjdXRlKCkgeyBmcHMuRXhlY3V0ZSgpOyB9CnByaXZhdGU6CiAgICBGIGZwczsKfTsKCmludCBtYWluKCkgewoJQ29udGFpbmVyIGM7CgljLkV4ZWN1dGUoKTsKCXJldHVybiAwOwp9