#include <iostream>
class Broken {
public:
Broken(int i): read_only(read_write), read_write(i) {}
int const& read_only;
void set(int i) { read_write = i; }
private:
int read_write;
};
int main() {
Broken original(5);
Broken copy(original);
std::cout << copy.read_only << "\n";
original.set(42);
std::cout << copy.read_only << "\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgQnJva2VuIHsKcHVibGljOgogICAgQnJva2VuKGludCBpKTogcmVhZF9vbmx5KHJlYWRfd3JpdGUpLCByZWFkX3dyaXRlKGkpIHt9CgogICAgaW50IGNvbnN0JiByZWFkX29ubHk7CgogICAgdm9pZCBzZXQoaW50IGkpIHsgcmVhZF93cml0ZSA9IGk7IH0KICAgIApwcml2YXRlOgogICAgaW50IHJlYWRfd3JpdGU7Cn07CgppbnQgbWFpbigpIHsKCUJyb2tlbiBvcmlnaW5hbCg1KTsKCUJyb2tlbiBjb3B5KG9yaWdpbmFsKTsKCQoJc3RkOjpjb3V0IDw8IGNvcHkucmVhZF9vbmx5IDw8ICJcbiI7CgkKCW9yaWdpbmFsLnNldCg0Mik7CgkKCXN0ZDo6Y291dCA8PCBjb3B5LnJlYWRfb25seSA8PCAiXG4iOwoJcmV0dXJuIDA7Cn0=