简单链接列表指针问题 [英] Simple linked lists pointer question

查看:48
本文介绍了简单链接列表指针问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这行代码有什么作用?

What does this line of code do?

p->next->next





这个怎么样:







what about this one:


p->next->data





如果我第一次做错了什么的,那就太好了。



SOrry if i did anything wrong 1st time.

推荐答案

p->next->next



在这种情况下我们正在遍历链表。

我们基本上是导航两个链接节点。


In this case we are traversing the linked list.
We are basically navigating two link nodes.

p->next->data



这里,我们导航到下一个链表节点,然后访问其数据值。


Here, we are navigating to the next linked list node and then accessing its data value.


引用:

p-> next-> next

p->next->next

将其视为两步操作:

See it as a two-steps operation:

p->next



为您提供指向列表下一个元素的指针,然后


gives you the pointer to the next element of the list, then

(p->next)->next



为您提供指向元素的指针紧接着下一个,即指向项目'距离2'的指针。






gives you the pointer to the element immediately following the next, that is the pointer to the item 'at distance 2'.


Quote:

p-> next-> data

p->next->data

使用类似的参数,你可以写

With a similar argument, you may write

(p->next)->data



显示您正在访问数据成员列表的下一个元素。


showing you are accessing the data member of the next element of the list.


这篇关于简单链接列表指针问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆