y*h 发帖数: 107 | 1 对于一个char* a,
a=0; 和 a=NULL; 有什么区别? 还是就是一回事?
谢谢 | l*****x 发帖数: 3431 | 2 往前翻翻,有大侠给了解释,比如前者可以delete,后者不行
【在 y*h 的大作中提到】 : 对于一个char* a, : a=0; 和 a=NULL; 有什么区别? 还是就是一回事? : : 谢谢
| c***g 发帖数: 472 | 3 I dont think so,
delete p does nothing if p is NULL
so a NULL pointer can be deleted
【在 l*****x 的大作中提到】 : 往前翻翻,有大侠给了解释,比如前者可以delete,后者不行
| y*h 发帖数: 107 | 4 我试了一下, 好象两者都能delete啊. 要命啊, 要命啊
【在 l*****x 的大作中提到】 : 往前翻翻,有大侠给了解释,比如前者可以delete,后者不行
| m******i 发帖数: 6 | 5 same. ascii value of NULL is 0.
【在 y*h 的大作中提到】 : 我试了一下, 好象两者都能delete啊. 要命啊, 要命啊 :
| y*h 发帖数: 107 | 6 说的太对了!
大牛, 但怎么能比较,让我看一下呢?
【在 c***g 的大作中提到】 : I dont think so, : delete p does nothing if p is NULL : so a NULL pointer can be deleted
| c***g 发帖数: 472 | 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 的大作中提到】 : 说的太对了! : 大牛, 但怎么能比较,让我看一下呢?
| t****t 发帖数: 6806 | 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 的大作中提到】 : 说的太对了! : 大牛, 但怎么能比较,让我看一下呢?
| G*O 发帖数: 706 | 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
|
|