#include <iostream> #include <cstdint> using namespace std; // Implement class Reg32 here class Reg32 { private: uint32_t value; public: // Initialize register with a 32-bit value Reg32(uint32_t v) : value(v) {} // Bitwise OR assignment Reg32& operator|=(uint32_t x) { value |= x; return *this; } // Bitwise AND assignment Reg32& operator&=(uint32_t x) { value &= x; return *this; } // Conversion operator for output operator uint32_t() const { return value; } }; int main() { uint32_t init, orVal, andVal; cin >> init >> orVal >> andVal; Reg32 reg(init); reg |= orVal; // bitwise OR reg &= andVal; // bitwise AND cout << (uint32_t)reg; return 0; }
Test Cases
Test Results
Input
8 5 14
Expected Output
12