avatar
一个简单的小问题# Programming - 葵花宝典
y*h
1
对于一个char* a,
a=0; 和 a=NULL; 有什么区别? 还是就是一回事?

谢谢
avatar
l*x
2
往前翻翻,有大侠给了解释,比如前者可以delete,后者不行

【在 y*h 的大作中提到】
: 对于一个char* a,
: a=0; 和 a=NULL; 有什么区别? 还是就是一回事?
:
: 谢谢

avatar
c*g
3
I dont think so,
delete p does nothing if p is NULL
so a NULL pointer can be deleted

【在 l*****x 的大作中提到】
: 往前翻翻,有大侠给了解释,比如前者可以delete,后者不行
avatar
y*h
4
我试了一下, 好象两者都能delete啊. 要命啊, 要命啊


【在 l*****x 的大作中提到】
: 往前翻翻,有大侠给了解释,比如前者可以delete,后者不行
avatar
m*i
5
same. ascii value of NULL is 0.

【在 y*h 的大作中提到】
: 我试了一下, 好象两者都能delete啊. 要命啊, 要命啊
:

avatar
y*h
6
说的太对了!
大牛, 但怎么能比较,让我看一下呢?

【在 c***g 的大作中提到】
: I dont think so,
: delete p does nothing if p is NULL
: so a NULL pointer can be deleted

avatar
c*g
7
According to the language definition, an integral constant expression with t
he value 0 in a pointer context is converted into a null pointer at compil
e time.
As a matter of style, many programmers prefer not to have unadorned 0
's scattered through their programs, some representing numbers and some repr
esenting pointers. Therefore, the preprocessor macro NULL is defined (by sev
eral headers, including and ) as a null pointer constant
, typically 0 or ((void *)0)
Using NULL

【在 y*h 的大作中提到】
: 说的太对了!
: 大牛, 但怎么能比较,让我看一下呢?

avatar
t*t
8
http://c-faq.com/null/index.html
everything you need to know or you do not need to know about NULL pointer

【在 y*h 的大作中提到】
: 说的太对了!
: 大牛, 但怎么能比较,让我看一下呢?

avatar
G*O
9
赞。

t
repr
sev
constant
back
bef

【在 c***g 的大作中提到】
: According to the language definition, an integral constant expression with t
: he value 0 in a pointer context is converted into a null pointer at compil
: e time.
: As a matter of style, many programmers prefer not to have unadorned 0
: 's scattered through their programs, some representing numbers and some repr
: esenting pointers. Therefore, the preprocessor macro NULL is defined (by sev
: eral headers, including and ) as a null pointer constant
: , typically 0 or ((void *)0)
: Using NULL

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。