C++ 位域操作 置0置1

	bitset<8> bp;
	unsigned char up = 0;

	cout << bp << endl;
	cout << (unsigned)up << endl;

	bp.set(3);
	up = up | (1UL<<3);

	cout << bp << endl;
	cout << (unsigned)up << endl;

	bp.reset(3);
	up = up & ~(1UL<<3);

	cout << bp << endl;
	cout << (unsigned)up << endl;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章