#include <iostream> using namespace std; // Define enum class Level enum class Level { LOW = 0, HIGH = 1 }; // Define class GpioPin with operator= and operator int() class GpioPin { private: Level lvl; public: GpioPin(Level level) : lvl(level) {}; void operator=(Level next) { lvl = next; } friend ostream& operator<<(ostream& os,const GpioPin& pin) { os << static_cast<unsigned int>(pin.lvl); return os; } }; int main() { int init, next; cin >> init >> next; GpioPin pin(static_cast<Level>(init)); pin = static_cast<Level>(next); cout << pin; return 0; }
Test Cases
Test Results
Input
0 1
Expected Output
1