#include <iostream>
#include <vector>
using namespace std;
class MyClass {
public:
MyClass() { std::cout << "Default constructor called" << std::endl; }
MyClass(const MyClass& other) { std::cout << "Copy constructor called" << std::endl; }
MyClass(MyClass&& other) { std::cout << "Move constructor called" << std::endl; }
MyClass& operator=(const MyClass& other) {
std::cout << "Copy assignment operator called" << std::endl;
return *this;
}
MyClass& operator=(MyClass&& other) {
std::cout << "Move assignment operator called" << std::endl;
return *this;
}
};
int main() {
MyClass a;
cout << "created a" << endl;
MyClass *ptr_a = &a;
cout << "created pointer" << endl;
MyClass& b = *ptr_a;
cout << "created b" << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCmNsYXNzIE15Q2xhc3MgewpwdWJsaWM6CiAgICBNeUNsYXNzKCkgeyBzdGQ6OmNvdXQgPDwgIkRlZmF1bHQgY29uc3RydWN0b3IgY2FsbGVkIiA8PCBzdGQ6OmVuZGw7IH0KICAgIE15Q2xhc3MoY29uc3QgTXlDbGFzcyYgb3RoZXIpIHsgc3RkOjpjb3V0IDw8ICJDb3B5IGNvbnN0cnVjdG9yIGNhbGxlZCIgPDwgc3RkOjplbmRsOyB9CiAgICBNeUNsYXNzKE15Q2xhc3MmJiBvdGhlcikgeyBzdGQ6OmNvdXQgPDwgIk1vdmUgY29uc3RydWN0b3IgY2FsbGVkIiA8PCBzdGQ6OmVuZGw7IH0KCiAgICBNeUNsYXNzJiBvcGVyYXRvcj0oY29uc3QgTXlDbGFzcyYgb3RoZXIpIHsKICAgICAgICBzdGQ6OmNvdXQgPDwgIkNvcHkgYXNzaWdubWVudCBvcGVyYXRvciBjYWxsZWQiIDw8IHN0ZDo6ZW5kbDsKICAgICAgICByZXR1cm4gKnRoaXM7CiAgICB9CgogICAgTXlDbGFzcyYgb3BlcmF0b3I9KE15Q2xhc3MmJiBvdGhlcikgewogICAgICAgIHN0ZDo6Y291dCA8PCAiTW92Z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