: 在成员之后的结构声明中做什么 [英] What does the : do in a struct declaration after a member

查看:17
本文介绍了: 在成员之后的结构声明中做什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在:

struct foo {
  unsigned bar : 2;
};

':2' 有什么作用?

What does the ': 2' do?

推荐答案

它声明了一个 位域.该数字以位为单位指定该成员的大小.

It declares a bit field. The number specifies the size of that member in bits.

这篇关于: 在成员之后的结构声明中做什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆