C ++中是否有“byte”数据类型? [英] Is there 'byte' data type in C++?
本文介绍了C ++中是否有“byte”数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果存在要包括的头文件?
If exists is there header file to include?
此代码给出编译错误:
#include <iostream>
using namespace std;
int main()
{
byte b = 2;
cout << b << endl;
return 0;
}
推荐答案
类型在C ++。然而,你可以总是包括来自标准库的bitset头,并为字节创建一个typedef:
No there is no byte data type in C++. However you could always include the bitset header from the standard library and create a typedef for byte:
typedef bitset<8> BYTE;
注意:由于WinDef.h定义了Windows代码的BYTE,因此您可能需要使用除BYTE如果您打算以Windows为目标。
NB: Given that WinDef.h defines BYTE for windows code, you may want to use something other than BYTE if your intending to target Windows.
这篇关于C ++中是否有“byte”数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文