I understand how linked lists work but this particular code is tough to grasp for me.
Its this leetcode problem (basically we are given address of a node which is to be deleted) whose solution can be implemented like the code snippet below:
1. class Solution {
2. public:
3.     void deleteNode(ListNode* node) {       
4.         ListNode* next = node->next;
5.         *node = *next;
6.         delete next;
7.     }
8. };
I know that:
- &nodewould mean the address of node variable
- nodemeans the value (information) stored at address called node
- *nodeis used to dereference the pointer variable called node.
My doubt:
- [IMP] If we need to dereference a nodepointer to get its data (like in line 5), then why not do so while accessing its member elements too (in line 4node->next)?
- [Not IMP] Then, how does *nodecopies*next's data?
 
     
    