检查指针是不是NULL通过简单写入if(pointer)或我必须使用它是否安全if(pointer != NULL)?
NULL
if(pointer)
if(pointer != NULL)
c++ null pointers if-statement null-pointer
在C++中,允许在for循环中具有空条件,例如在for (;;)或中for (int x = 0;; ++x).但你做不到while ().
for (;;)
for (int x = 0;; ++x)
while ()
当在for循环中省略条件时,假定条件为true(因此循环永远循环).为什么这不是while循环的情况,也就是说,背后的论点是什么,不让它while ()成为别名while (true)?
true
while
while (true)
c++ syntax loops
c++ ×2
if-statement ×1
loops ×1
null ×1
null-pointer ×1
pointers ×1
syntax ×1