#include <iostream> #include <cstdint> using namespace std; // Implement class Reg32 here class Reg32{ uint32_t reg_val; public: Reg32(uint32_t val){reg_val = val;} Reg32 &operator|=(const Reg32 &other){ reg_val|=other; return *this; } Reg32 operator&=(const Reg32 &other){ reg_val&=other; return *this; } operator uint32_t()const{ return reg_val; } }; 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