Gusare #include <iostream> class MyClass { int* data; public: MyClass(int value) { data = new int(value); std::cout << "Constructor called. Value = " << *data << std::endl; } MyClass(MyClass&& other) noexcept { std::cout << "Move Constructor called." << std::endl; data = other.data; other.data = nullptr; } MyClass& operator=(MyClass&& other) noexcept { std::cout << "Move Assignment Operator called." << std::endl; if (this == &other) return *this; delete data; data = other.data; other.data = nullptr; return *this; } ~MyClass() { if (data) { std::cout << "Destructor called. Freeing memory = " << *data << std::endl; delete data; } else { std::cout << "Destructor called. Nothing to free." << std::endl; } } void show() const { if (data) { std::cout << "Value: " << *data << std::endl; } else { std::cout << "Data is null." << std::endl; } } }; int main() { MyClass obj1(10); MyClass obj2(20); obj2 = std::move(obj1); // 调用移动赋值运算符 obj2.show(); obj1.show(); return 0; } 哎都要2025了学校为什么还只教c++98啊