All submissions
#include <iostream>
#include <cstdint>
using namespace std;

class Flags {
private:
   uint8_t bits;
public:
   Flags(uint8_t b) : bits(b) {}
   // your code here: define operator~ to invert bits
   uint8_t operator~() {
      return ~bits;
   }
   uint8_t getBits() const {
       return bits;
   }
};

int main() {
   int val;
   cin >> val;
   Flags f(val);
   Flags toggled = ~f; // must use overloaded operator
   cout << "Toggled=" << (int)toggled.getBits();
   return 0;
}
Loading...

Input

0

Expected Output

Toggled=255