bitfield.cpp

来自「C++ sample code, for the book: C++ blac」· C++ 代码 · 共 27 行

CPP
27
字号
#include <iostream>
using namespace std;

int main()
{
    struct flags
    {
        int color : 4;
        bool line_flag : 1;
        bool brush_flag : 1;
        bool ellipse_flag : 1;
        bool rectangle_flag : 1;
    };

    flags current_flags;
    current_flags.rectangle_flag = 1;

    if(current_flags.rectangle_flag){
        cout << "You're drawing rectangles.";
    } else {
        cout << "You're not drawing rectangles.";
    }

    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?