【发布时间】:2012-03-24 14:52:29
【问题描述】:
可能重复:
What can I use instead of the arrow operator,->?
What does -> mean in C++?
所以我目前正在学习有关数据结构和算法开发的 C++ 考试。在查看我的老师的幻灯片时,我注意到他经常使用这个“->”。我不确定这意味着什么?它真的是你可以在 C++ 中执行的命令吗?
示例 1
addrInfo *ptr = head;
while (ptr->next != NULL)
{
ptr = ptr->next;
}
// at this point, ptr points to the last item
示例 2
if( head == NULL )
{
head = block;
block->next = NULL;
}
【问题讨论】:
-
只是附加注释,
->运算符称为“指向成员的指针”运算符。我不知道为什么这么多人没有给它起名字。
标签: c++ pointers linked-list