All submissions

Compare Register Values

#include <iostream>
#include <cstdint>
using namespace std;

class Register8 {
private:
    uint8_t value;

public:
    // Constructor
    Register8(uint8_t v) : value(v) {}

    // Define operator+ to add two Register8 objects
    Register8 operator+(const Register8& other) const {
        return Register8(value + other.value);  // automatic uint8_t overflow wrap-around
    }

    // Define operator== to compare two Register8 objects
    bool operator==(const Register8& other) const {
        return value == other.value;
    } 

    uint8_t getValue() const {
        return value;
    }
};

int main() {
    int a, b;
    cin >> a >> b;

    Register8 r1(a);
    Register8 r2(b);

    if (r1 == r2)
        cout << "Equal";
    else
        cout << "Not Equal";

    return 0;
}
Loading...

Input

10 10

Expected Output

Equal