箭VS点语法? [英] Arrow vs dot syntax?

查看:68
本文介绍了箭VS点语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个朋友走的是数据结构课程,我试图解释一个链表的背景的差异。我真的应该知道这一点,但已经专注于高层次的框架,我有点生疏了。我知道,箭与指针使用,但仅此而已。

A friend is taking a data structures course and I'm trying to explain the difference in the context of a linked list. I really should know this, but having focused on high level frameworks, I'm a little rusty. I know that "arrows are used with pointers", but that's it.

从本质上讲,在C,什么是点与和访问某些变量的属性时,箭头之间的区别?另外,因为我在一个特别愚蠢的心情来的,这是在C ++中一样,还是改变它?

Essentially, in C, what's the difference between a dot and and an arrow when accessing a property of some variable? Also, because I'm in a particularly stupid mood, is this the same in C++, or did it change?

推荐答案

通常情况下,当你有一个结构的直接访问,而<$ C $使用C> - 方式&gt; 当你有一个指向一个结构,需要取消引用它来访问结构

Normally the . is used when you have a structure to access directly, and the -> when you have a pointer to a structure and need to dereference it to access the structure.

A-&GT; b 语法糖(*一).B 。它在C和C ++一样的。

a->b is syntactic sugar for (*a).b. It's the same in both C and C++.

这篇关于箭VS点语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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