#include <iostream> using namespace std; // Define enum class Level // Define class GpioPin with operator= and operator int() enum class Level { LOW = 0, HIGH = 1 }; class GpioPin { private: Level level; public: explicit GpioPin(Level l) : level(l) {} GpioPin& operator=(Level l) { level = l; return *this; } operator int() const { return static_cast<int>(level); } }; 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