#include <iostream> using namespace std; // Define enum class Level enum class Level{ LOW=0,HIGH }; // Define class GpioPin with operator= and operator int() class GpioPin{ Level pin; public: GpioPin(Level p) : pin(p){} void operator=(const Level&o){ pin=o; } operator int()const{ return static_cast<int>(pin); } }; 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