#include <iostream>
using namespace std;
class Foo {
public:
void func(int param) { cout << param << endl; }
void (Foo::*getPointer())(int) { return &Foo::func; }
};
class Bar {
Foo foo;
public:
Bar(Foo param) : foo(param) {}
void print(int param) {
void (Foo::*func)(int) = foo.getPointer();
(foo.func)(param);
}
};
int main() {
Foo foo;
Bar bar(foo);
bar.print(13);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIEZvbyB7CnB1YmxpYzoKCXZvaWQgZnVuYyhpbnQgcGFyYW0pIHsgY291dCA8PCBwYXJhbSA8PCBlbmRsOyB9Cgl2b2lkIChGb286OipnZXRQb2ludGVyKCkpKGludCkgeyByZXR1cm4gJkZvbzo6ZnVuYzsgfQp9OwoKY2xhc3MgQmFyIHsKCUZvbyBmb287CnB1YmxpYzoKCUJhcihGb28gcGFyYW0pIDogZm9vKHBhcmFtKSB7fQoJdm9pZCBwcmludChpbnQgcGFyYW0pIHsKCQl2b2lkIChGb286OipmdW5jKShpbnQpID0gZm9vLmdldFBvaW50ZXIoKTsKCgkJKGZvby5mdW5jKShwYXJhbSk7Cgl9Cn07CgppbnQgbWFpbigpIHsKCUZvbyBmb287CglCYXIgYmFyKGZvbyk7CgoJYmFyLnByaW50KDEzKTsKCXJldHVybiAwOwp9