#include <iostream>
using namespace std;
class SomeClass
{
private:
int i = 0;
public:
SomeClass() { cout << "default constructor\n"; };
SomeClass(int val) { i = val; cout << "constructor getting int: " << val << '\n'; };
~SomeClass() { cout << "destrucing object having i: " << i << '\n'; };
SomeClass& operator=(const SomeClass& rhs) {
cout << "operator= getting int: " << rhs.i << '\n';
if (this != &rhs) {
i = rhs.i;
}
return *this;
}
};
int main() {
SomeClass a(10);
SomeClass b = SomeClass(20);
SomeClass c(35);
c = SomeClass(46);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgU29tZUNsYXNzCnsKcHJpdmF0ZToKCWludCBpID0gMDsKCQpwdWJsaWM6CglTb21lQ2xhc3MoKSB7IGNvdXQgPDwgImRlZmF1bHQgY29uc3RydWN0b3JcbiI7IH07CglTb21lQ2xhc3MoaW50IHZhbCkgeyBpID0gdmFsOyBjb3V0IDw8ICJjb25zdHJ1Y3RvciBnZXR0aW5nIGludDogIiA8PCB2YWwgPDwgJ1xuJzsgfTsKCX5Tb21lQ2xhc3MoKSB7IGNvdXQgPDwgImRlc3RydWNpbmcgb2JqZWN0IGhhdmluZyBpOiAiIDw8IGkgPDwgJ1xuJzsgfTsKCQoJU29tZUNsYXNzJiBvcGVyYXRvcj0oY29uc3QgU29tZUNsYXNzJiByaHMpIHsgCgkJY291dCA8PCAib3BlcmF0b3I9IGdldHRpbmcgaW50OiAiIDw8IHJocy5pIDw8ICdcbic7CgkJaWYgKHRoaXMgIT0gJnJocykgewoJCQlpID0gcmhzLmk7CgkJfQoJCXJldHVybiAqdGhpczsKCX0KfTsKCmludCBtYWluKCkgewoJU29tZUNsYXNzIGEoMTApOwoJU29tZUNsYXNzIGIgPSBTb21lQ2xhc3MoMjApOwoJU29tZUNsYXNzIGMoMzUpOwoJYyA9IFNvbWVDbGFzcyg0Nik7CglyZXR1cm4gMDsKfQ==