首页 > 解决方案 > ':' 在结构字段声明中是什么意思?

问题描述

今天,我在这个网站上看到了一个对我来说很新的例子。提供的示例如下:

struct S {
    char a;     // memory location #1
    int b : 5;  // memory location #2
    int c : 11, // memory location #2 (continued)
          : 0,
        d : 8;  // memory location #3
    struct {
        int ee : 8; // memory location #4
    } e;
} obj; // The object 'obj' consists of 4 separate memory locations

我对这个例子中的 ':' 有点困惑,“int b : 5;”是什么意思?在这个例子中是什么意思?

标签: c++

解决方案


推荐阅读