Home > other >  Using the !(not) operator when referring to a variable in a different class [closed]
Using the !(not) operator when referring to a variable in a different class [closed]

Time:09-17

I have created an object from the class HapticDevice and would like to use the !(not) operator when referring to device, but this leads it to change the variable name. What to do guys

Example code:

            HapticsDevice haptic_device;
            if (haptic_device.!device.get()) return; 

CodePudding user response:

If you want to get haptic_device.device, NOT it, and then call get on the result of the not, it is (!haptic_device.device).get(). This is the same as (!(haptic_device.device)).get() since . has precedence over !. In fact, . has very high precedence.

I suspect you actually want !haptic_device.device.get() though which is the same as !(haptic_device.device.get()) i.e. call get() and then call ! on what get() returns.

  • Related