#include <iostream>
struct S {
int a ;
};
int main() {
S s1;
S s2;
s1.a = 1;
s2.a = 2;
const S* p = &s1;
//p->a = 1; // does not work, read it from right to left as S const* p (pointer on constant S).
p = &s2;
std::cout << p->a << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IFMgewoJaW50IGEgOwp9OwoKaW50IG1haW4oKSB7CglTIHMxOwoJUyBzMjsKCXMxLmEgPSAxOwoJczIuYSA9IDI7CgkKCWNvbnN0IFMqIHAgPSAmczE7CgkvL3AtPmEgPSAxOyAvLyBkb2VzIG5vdCB3b3JrLCByZWFkIGl0IGZyb20gcmlnaHQgdG8gbGVmdCBhcyBTIGNvbnN0KiBwIChwb2ludGVyIG9uIGNvbnN0YW50IFMpLgoJCglwID0gJnMyOwoJc3RkOjpjb3V0IDw8IHAtPmEgPDwgc3RkOjplbmRsOwoJcmV0dXJuIDA7Cn0=