// two-bit state and operations // #include #include "B2.h" using namespace std; B2::B2() { b1 = b0 = 0; } void B2::print(const char msg[]) const { cout << msg << ": " << b1 << " " << b0 << endl; } void B2::X() { b1 = !b1; } // NOT, bit 1 void B2::CX() { if( b1) b0 = !b0; } // controlled-NOT on bit 0 controlled by bit 1 int B2::M() { return b1; } // measure, bit 1