#pragma once
class CBit
{
public:
    enum VALUE {
        ZERO = 0,
        ONE = 1
    };

protected:
    VALUE m_nValue;

public:
    CBit(VALUE nVal = ZERO);
    virtual ~CBit();

    inline void Set()
    {
        m_nValue = ONE;
    };
    inline void Clear()
    {
        m_nValue = ZERO;
    };
    inline unsigned Get()
    {
        if (m_nValue == ONE)
            return 1;
        else
            return 0;
    };

    void Print();

    CBit &operator=(unsigned d)
    {
        if (d == 0 ) {
            m_nValue = ZERO;
        } else {
            m_nValue = ONE;
        }
        return *this;
    }

    friend CBit operator^(CBit l, const CBit &r)
    {
        if (l.m_nValue == r.m_nValue) {
            return CBit(ZERO);
        } else {
            return CBit(ONE);
        }
    }

    CBit &operator^=(const CBit &r)
    {
        if (m_nValue == r.m_nValue) {
            m_nValue = ZERO;
        } else {
            m_nValue = ONE;
        }
        return *this;
    }

    inline bool operator==(const CBit::VALUE &r)
    {
        return m_nValue == r;
    }
};

