1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| #include <iostream> #include <bitset>
using std::cout; using std::endl; using std::bitset;
int main() { bitset<4> bitset_quizl; unsigned long int_quizl = 0; cout << "bitset:" << bitset_quizl << "int_quizl:" << int_quizl << endl;
bitset_quizl.set(2); int_quizl |= 1UL << 2; cout << "bitset:" << bitset_quizl << "int_quizl:" << int_quizl << endl;
bitset_quizl.reset(2); int_quizl &= ~(1UL << 2); cout << "bitset:" << bitset_quizl << "int_quizl:" << int_quizl << endl;
bool status1= bitset_quizl[2]; bool status2 = int_quizl & (1UL << 2); cout << "bitset status: " << status1 << "int_quizl status :" << status2; return 0; }
|