前言
code
#include <iostream> typedef struct { unsigned int a : 5; unsigned int b : 3; } tBits; int main() { tBits aa; aa.a = 205; // 1100 1101 aa.b = 89; // 0101 1001 std::cout << "a: " << aa.a << std::endl; std::cout << "b: " << aa.b << std::endl; }
参考
1. C++ 位域;
2. C/C++位域详解整理_劣@巛弧的博客-CSDN博客;
完
标签:aa,int,unsigned,c++,tBits,C++,位域,结构 From: https://www.cnblogs.com/happyamyhope/p/17511473.html