class Encapsulator
{
protected:
int i;
public:
Encapsulator(int v) : i(v) {}
};
Encapsulator f(int x) { return x + 2; }
#include <iostream>
int main( void )
{
Encapsulator e = f(7);
// forbidden: std::cout << e.i << std::endl;
struct Gimme : Encapsulator { static int Encapsulator::* it() { return &Gimme::i; } };
int Encapsulator::*pi = Gimme::it();
std::cout << e.*pi << std::endl;
}
Y2xhc3MgRW5jYXBzdWxhdG9yCnsKICBwcm90ZWN0ZWQ6CiAgICBpbnQgaTsKICBwdWJsaWM6CiAgICBFbmNhcHN1bGF0b3IoaW50IHYpIDogaSh2KSB7fQp9OwoKRW5jYXBzdWxhdG9yIGYoaW50IHgpIHsgcmV0dXJuIHggKyAyOyB9CgojaW5jbHVkZSA8aW9zdHJlYW0+CmludCBtYWluKCB2b2lkICkKewogICAgRW5jYXBzdWxhdG9yIGUgPSBmKDcpOwogICAgLy8gZm9yYmlkZGVuOiBzdGQ6OmNvdXQgPDwgZS5pIDw8IHN0ZDo6ZW5kbDsKICAgIHN0cnVjdCBHaW1tZSA6IEVuY2Fwc3VsYXRvciB7IHN0YXRpYyBpbnQgRW5jYXBzdWxhdG9yOjoqIGl0KCkgeyByZXR1cm4gJkdpbW1lOjppOyB9IH07CiAgICBpbnQgRW5jYXBzdWxhdG9yOjoqcGkgPSBHaW1tZTo6aXQoKTsKICAgIHN0ZDo6Y291dCA8PCBlLipwaSA8PCBzdGQ6OmVuZGw7Cn0K