我有以下课程:
class BluetoothAddress
{
public:
BluetoothAddress();
BluetoothAddress(const unsigned char* address);
BluetoothAddress(const BluetoothAddress& bluetoothAddress);
~BluetoothAddress();
BluetoothAddress& operator=(const BluetoothAddress& other);
BluetoothAddress(BluetoothAddress&& other) = delete;
BluetoothAddress& operator=(BluetoothAddress&& other) = delete;
unsigned char address[BLUETOOTH_ADDRESS_LENGTH];
};
以下功能:
BluetoothAddress Create()
{
unsigned char addr = { 0x12, 0x34, 0x56, 0x78 0x9A, 0xBC };
return BluetoothAddress(addr);
}
我在尝试编译时收到了这个:
错误C2280'BluetoothAddress :: BluetoothAddress(BluetoothAddress&&)': 试图引用已删除的功能
我不需要移动构造函数,因为堆上没有任何需要移动的资源。 (接收unsigned int*
的构造函数只是通过char复制循环char中的值。
为什么编译器试图调用移动构造函数而不是复制构造函数?