true/TRUE和null/NULL之间的差异 [英] Differences between true/TRUE and null/NULL
本文介绍了true/TRUE和null/NULL之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好.
我有一个小问题,似乎无法找到一个好的答案.
true/false
和TRUE/FALSE
之间的区别是什么(小写字母与大写字母).在大多数情况下,似乎并没有真正的区别,但在某些情况下确实会收到警告.
还有... null
和NULL
有什么区别?
我能弄清楚的是,这与从C到C ++的开发有关吗?
感觉像一个愚蠢的问题...但是我真的没有头绪. :cool:
Hello out there.
I have a small question that I seem unable to find a good answer at.
What is the differences between true/false
and TRUE/FALSE
(small vs cap. letters). In most cases it seems there are no real differences but I do get warnings in some cases.
Also... what is the difference between null
and NULL
?
All I can figure out is that this has something with the developmen from C to C++?
Feels like a stupid question... but I don''t really have a clue. :cool:
推荐答案
true和false只是bool类型的有效值
bool mybool = true;
TRUE是#define TRUE 1,即整数值1
FALSE是#define FALSE 0,即整数值0
适用于BOOL
#define BOOL int
BOOL myBOOL = TRUE;
这也是可能的
myBOOL = 6;
这就是为什么引入bool
nullptr指向没有地址/值的指针(我认为是c#,它为null)
NULL是#define NULL 0,但出于传统原因在其中用作nullptr
TRUE,FALSE和NULL是#出于传统原因在其中定义
true,false,nullptr是该语言的一部分,并被编译器识别
true and false are only valid values for type bool
bool mybool = true;
TRUE is #define TRUE 1 i.e. integer value 1
FALSE is #define FALSE 0 i.e. integer value 0
applied to BOOL
#define BOOL int
BOOL myBOOL = TRUE;
This is also possible
myBOOL = 6;
which is why bool was introduced
nullptr refers to a pointer with no address/value (null I think is c#)
NULL is #define NULL 0 but used as nullptr there for legacy reasons
TRUE, FALSE, NULL are #defines there for legacy reasons
true, false, nullptr are part of the language and recognised by the compiler
这篇关于true/TRUE和null/NULL之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文