[ 用户登陆 ] [ 免费注册 

Class >> 学习资料 > 程序技术 > VC >
BOOL和bool的区别
文 . 2011/10/5 13:29:19
一、
1、类型不同
BOOL为int型
bool为布尔型
2、长度不同
bool只有一个字节
BOOL长度视实际环境来定,一般可认为是4个字节
3、取值不同
bool取值false和true,是0和1的区别
BOOL取值FALSE和TRUE,是0和非0的区别

二:
bool是标准C++数据类型,可取值true和false。单独占一个字节,
如果数个bool对象列在一起,可能会各占一个bit,这取决于编译器。

BOOL是微软定义的typedef int BOOL。与bool不同,它是一个三值逻辑,
TRUE/FALSE/ERROR,返回值为>0的整数为TRUE,0为FALSE,-1为ERROR。
Win32 API中很多返回值为BOOL的函数都是三值逻辑。比如GetMessage().

三:
大BOOL和小bool之间的区别:
1、类型不同
BOOL为int型
bool为布尔型
2、长度不同
bool只有一个字节
BOOL长度视实际环境来定,一般可认为是4个字节
3、取值不同
bool取值false和true,是0和1的区别
BOOL取值FALSE和TRUE,是0和非0的区别
4、例子
bool x=3;  //告警
bool x=1;  //正确
BOOL x=3;  //正确
BOOL x=3.3;  //告警
注:windows为了兼容问题定义的基础变量。
typedef unsigned long        DWORD;
typedef int                  BOOL;
typedef unsigned char        BYTE;
typedef unsigned short      WORD;
typedef float                FLOAT;
typedef FLOAT                *PFLOAT;
typedef BOOL near            *PBOOL;
typedef BOOL far            *LPBOOL;
typedef BYTE near            *PBYTE;
typedef BYTE far            *LPBYTE;
typedef int near            *PINT;
typedef int far              *LPINT;

 URL: http://www.cppblog.com/Lee7/archive/2008/12/14/69394.html 


最近后的内容
VS2003 中配置Microsoft PlatformSDK2003
vc++实现U盘介质加密解密保障存储安全
error C2440: “static_cast”: 无法从“UINT (__thiscall CCoolControlBar::* )(CPoint)”转换为“LRESULT (__thiscall CWnd::* )(CPoint)”
error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) 已经在 LIBCMT.lib(new.obj) 中定义
warning C4996: 'sprintf': This function or variable may be unsafe
最近前的内容
wsprintf用法
C++命名书写规范/MFC、句柄、控件及结构的命名规范
C语言类型范围
error C2440: "static_cast": 无法从"void (__thiscall CChat::* )(WPARAM,LPARAM)"转换为"LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)"
最受欢迎
C语言类型范围
error C2440: "static_cast": 无法从"void (__thiscall CChat::* )(WPARAM,LPARAM)"转换为"LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)"
C++命名书写规范/MFC、句柄、控件及结构的命名规范
VS2003 中配置Microsoft PlatformSDK2003
error C2440: “static_cast”: 无法从“UINT (__thiscall CCoolControlBar::* )(CPoint)”转换为“LRESULT (__thiscall CWnd::* )(CPoint)”
warning C4996: 'sprintf': This function or variable may be unsafe
BOOL和bool的区别
vc++实现U盘介质加密解密保障存储安全
error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) 已经在 LIBCMT.lib(new.obj) 中定义
wsprintf用法
 ©2005 - 2008 粤ICP备12037054号-1 用户登陆  |  互联说明  |  联系我们  |  网站地图