#include <iostream>
#include <cstdio>
using namespace std;
class A {
public:
virtual void func() { cout << "i: " << i_ << endl; }
void inc() { ++i_; }
A() { i_=10; }
private:
int i_;
};
int main() {
void (A::*p)() = &A::func;
int size = sizeof(p)/sizeof(unsigned int);
cout << "size: " << size << endl;
unsigned int *t = new unsigned int[size];
for (int i = 0; i < size; ++i) t[i] = ((unsigned int *)&p)[i];
void (A::*q)() = *(void (A::**)())t;
delete [] t;
A a;
(a.*q)();
a.inc();
(a.*q)();
A aa;
(aa.*q)();
(a.*q)();
(aa.*q)();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIEEgewogcHVibGljOgogIHZpcnR1YWwgdm9pZCBmdW5jKCkgeyBjb3V0IDw8ICAiaTogIiA8PCAgaV8gPDwgZW5kbDsgfQogIHZvaWQgaW5jKCkgeyArK2lfOyB9CiAgQSgpIHsgaV89MTA7IH0KIHByaXZhdGU6CiAgaW50IGlfOwp9OwogCmludCBtYWluKCkgewogIHZvaWQgKEE6OipwKSgpID0gJkE6OmZ1bmM7CiAgaW50IHNpemUgPSAgc2l6ZW9mKHApL3NpemVvZih1bnNpZ25lZCBpbnQpOwogIGNvdXQgPDwgInNpemU6ICIgPDwgc2l6ZSA8PCBlbmRsOwogIHVuc2lnbmVkIGludCAqdCA9IG5ldyB1bnNpZ25lZCBpbnRbc2l6ZV07CiAgZm9yIChpbnQgaSA9IDA7IGkgPCBzaXplOyArK2kpIHRbaV0gPSAoKHVuc2lnbmVkIGludCAqKSZwKVtpXTsKICB2b2lkIChBOjoqcSkoKSA9ICoodm9pZCAoQTo6KiopKCkpdDsKICBkZWxldGUgW10gdDsKCiAgQSBhOwogIChhLipxKSgpOwogIGEuaW5jKCk7CiAgKGEuKnEpKCk7CgogIEEgYWE7CiAgKGFhLipxKSgpOwogIChhLipxKSgpOwogIChhYS4qcSkoKTsKCiAgcmV0dXJuIDA7Cn0KCgo=