问下if(!head->next || !head->next[0])解决方案
问下if(!head->next || !head->next[0])
问下这个代码的意思。
当(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/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;