#include <iostream>
class Foo
{
private:
int m_data;
public:
Foo(int data)
: m_data(data)
{
}
Foo& operator=(const Foo& other)
{
if (this == &other)
{
return *this;
}
m_data = other.m_data;
return *this;
}
int GetData()
{
return m_data;
}
};
int main()
{
auto a = Foo(42);
auto b = Foo(24);
auto c = Foo(10);
a = b = c;
std::cout << &a << ": " << a.GetData() << std::endl;
std::cout << &b << ": " << b.GetData() << std::endl;
std::cout << &c << ": " << c.GetData() << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgRm9vCnsKcHJpdmF0ZToKCWludCBtX2RhdGE7CgkKcHVibGljOgoJRm9vKGludCBkYXRhKQoJOiBtX2RhdGEoZGF0YSkKCXsKCQkKCX0KCglGb28mIG9wZXJhdG9yPShjb25zdCBGb28mIG90aGVyKQoJewoJCWlmICh0aGlzID09ICZvdGhlcikKCQl7CgkJCXJldHVybiAqdGhpczsKCQl9CgkJCgkJbV9kYXRhID0gb3RoZXIubV9kYXRhOwoJCXJldHVybiAqdGhpczsKCX0KCQoJaW50IEdldERhdGEoKQoJewoJCXJldHVybiBtX2RhdGE7Cgl9Cn07CgppbnQgbWFpbigpIAp7CglhdXRvIGEgPSBGb28oNDIpOwoJYXV0byBiID0gRm9vKDI0KTsKCWF1dG8gYyA9IEZvbygxMCk7CgkKCWEgPSBiID0gYzsKCQoJc3RkOjpjb3V0IDw8ICZhIDw8ICI6ICIgPDwgYS5HZXREYXRhKCkgPDwgc3RkOjplbmRsOwoJc3RkOjpjb3V0IDw8ICZiIDw8ICI6ICIgPDwgYi5HZXREYXRhKCkgPDwgc3RkOjplbmRsOwoJc3RkOjpjb3V0IDw8ICZjIDw8ICI6ICIgPDwgYy5HZXREYXRhKCkgPDwgc3RkOjplbmRsOwoJCglyZXR1cm4gMDsKfQ==