读书人

问下if(!head-gt;next || !head-gt;next[0

发布时间: 2012-02-13 17:20:26 作者: rapoo

问下if(!head->next || !head->next[0])

C/C++ code
if(!head->next || !head->next[0])    return -1;return head->next[0]->data;


问下这个代码的意思。
当(head没有指向next或者head没有指向数组next[0]的时候)
就返回-1;
否则就返回head指向数组指向data?

是这样?

[解决办法]
if(!head->next/*判断next指针是否为NULL*/ || !head->next[0] /*判断next指针指向的内存首字节是否为0*/)
return -1;//如果条件都满足(不是NULL和0)
return head->next[0]->data;



读书人网 >C++

热点推荐