38. 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:

 Toggled=<value>

 

Example
 Input:

0

Output:

Toggled=255

 

Input:

255

Output:

Toggled=0

 

Input:

170

Output:

Toggled=85

 

Loading...

Input

0

Expected Output

Toggled=255