34. Toggle Bitmask

 The class Flags is already defined with a private variable bits, a constructor, and a getter.

Your task is to define the ~ operator so that applying ~flags creates a new Flags object with all bits inverted.

In main() we are:

  • Read an integer (initial flag value).
  • Create a Flags object.
  • Apply the overloaded ~ operator.
     

Print the toggled result in the format:

Input=<Input value> Toggled Input=<toggled value>

 

Example
 Input:

0

Output:

Input=0 Toggled Input=255

 

Input:

255

Output:

Input=255 Toggled Input=0

 

Input:

170

Output:

Input=170 Toggled Input=85

 

Loading...

Input

0

Expected Output

Input=0 Toggled Input=255