Create a class GpioPin that simulates a single digital GPIO pin used in embedded systems.
The pin can hold only one of two logic levels:
The pin state must be represented using a strongly typed enumeration.
enum class Level { LOW = 0, HIGH = 1 };The class must support intuitive read and write semantics using operator overloading, similar to how GPIO abstractions are used in embedded firmware.
Functional Requirements
Your GpioPin class must support:
✔ Writing to the pin using an overloaded assignment operator
pin = Level::HIGH;✔ Reading the pin using an overloaded type conversion operator
int value = pin; // must return 0 or 1 Program Behavior
Input format
initial_level new_levelWhere:
initial_level is either 0 (LOW) or 1 (HIGH)new_level is either 0 (LOW) or 1 (HIGH)Execution Steps
GpioPin object using initial_levelnew_level using the overloaded operator=0 or 1)
Example 1
Input:
0 1
Execution Explanation:
Output:
1
Example 2
Input:
1 0
Output:
0
Constraints
enum class Leveloperator=operator int()
Input
0 1
Expected Output
1