Copy Operators

Module classes have overloaded copy assignment operators and copy constructors (see Self Devices for a list of standard module classes).

For devices that are not Self Devices, the copy assignment operator and copy constructor will initialize the object and copy the pointer to the WMX3Api object from the source. Therefore, the object will share the same device as the source.

The following is an example of using the copy constructor for a non-self device.

WMX3Api wmxlib;
CoreMotion wmxlib_cm(&wmxlib);    //Uses the device created by wmxlib
CoreMotion wmxlib_cm2(wmxlib_cm); //Uses the same device as wmxlib_cm

For devices that are Self Devices, the copy assignment operator and copy constructor will initialize the object and create a new self device for the object. Therefore, the object will not share the same device as the source.

The following is an example of using the copy assignment operator for a self device.

WMX3Api wmxlib;
CoreMotion wmxlib_cm(&wmxlib); //Uses the device created by wmxlib
CoreMotion wmxlib_cm2;         //Uses a self device

wmxlib_cm = wmxlib_cm2; //wmxlib_cm will create a new self device