当您尝试切换指针时,“=”是什么意思。
例如:current->next = previous和current = previous。
让我们来做第二个作业,current = previous。在这里,小方框是指针本身的值,而右边的矩形是它们所指向的东西。
分配前:
+---+ +-----------+
current | --|--------> | Obj1 |
+---+ +-----------+
+---+ +-----------+
previous | --|--------> | Obj2 |
+---+ +-----------+
赋值后,两者都current指向previous 对象Obj2。
+---+ +-----------+
current | --|--+ | Obj1 |
+---+ | +-----------+
|
+---+ +-----> +-----------+
previous | --|--------> | Obj2 |
+---+ +-----------+
重要要点:
current没有改变。它不会因分配而“删除”或破坏。Obj1也不Obj2修改它们自己。*current = func()访问(读取)它时,将反映其更改的状态。 currentprevious