// single-bit state and operations // // #ifndef B1_H_ // #define B1_H_ class B1 { private: int b; public: B1(); void print(const char msg[]) const; void X(); int M(); // NOT, measure }; // #endif // B1_H_ // single-bit state and operations // #include // #include "B1.h" using namespace std; B1::B1() { b = 0; } void B1::print(const char msg[]) const { cout << msg << ": " << b << endl; } void B1::X() { b = !b; } // NOT int B1::M() { return b; } // measure #include // #include "B1.h" using namespace std; int main() { B1 b; b.print("b"); cout << "m = " << b.M() << endl; b.X(); b.print("X"); cout << "m = " << b.M() << endl; }