#include <iostream>
void dangerous( int const** lhs, int const** rhs )
{
*lhs = *rhs;
}
int main() {
int* pBar = nullptr;
int const foo = 7;
int const* pFoo = &foo;;
dangerous(const_cast<int const**>(&pBar), &pFoo);
std::cout << pBar << "," << pFoo << "\n";
std::cout << *pBar << "," << *pFoo << "\n";
*pBar = 2; // undefined behavior!
std::cout << foo << "," << &foo << "\n";
std::cout << *pBar << "," << pBar << "\n";
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdm9pZCBkYW5nZXJvdXMoIGludCBjb25zdCoqIGxocywgaW50IGNvbnN0KiogcmhzICkKewoJKmxocyA9ICpyaHM7Cn0KaW50IG1haW4oKSB7CglpbnQqIHBCYXIgPSBudWxscHRyOwoJaW50IGNvbnN0IGZvbyA9IDc7CglpbnQgY29uc3QqIHBGb28gPSAmZm9vOzsKCWRhbmdlcm91cyhjb25zdF9jYXN0PGludCBjb25zdCoqPigmcEJhciksICZwRm9vKTsKCXN0ZDo6Y291dCA8PCBwQmFyIDw8ICIsIiA8PCBwRm9vIDw8ICJcbiI7CglzdGQ6OmNvdXQgPDwgKnBCYXIgPDwgIiwiIDw8ICpwRm9vIDw8ICJcbiI7CgkqcEJhciA9IDI7IC8vIHVuZGVmaW5lZCBiZWhhdmlvciEKCXN0ZDo6Y291dCA8PCBmb28gPDwgIiwiIDw8ICZmb28gPDwgIlxuIjsKCXN0ZDo6Y291dCA8PCAqcEJhciA8PCAiLCIgPDwgcEJhciA8PCAiXG4iOwoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJcmV0dXJuIDA7Cn0=