Wrenpo
How to start coding C# in vs code??
You need the .NET SDK
https://dotnet.microsoft.com/en-us/download/visual-studio-sdks
3 replies
Studying singly linked lists and need help understanding pointer functionality
Car
and ListNode
are objects and go on the heap, including their properties. The local variables myCar
, newCar
, dummy
, and current
are on the stack. When I code current.next
or myCar.IsRunning
, I am referring to the heap object and not the local variable?18 replies
Studying singly linked lists and need help understanding pointer functionality
So I guess the following would be true if my understanding is correct:
Basically, if I change the new object that references the previous object to a new object or null, only the new object changes.
However, in the original code block, during the while loop,
current.Next
still updates the links between the nodes. Is this because the property is the same as the object?18 replies
Studying singly linked lists and need help understanding pointer functionality
What documentation can I look up to learn more about this? When doing searches around variables, pass-by-value, pointers, addresses, I get thrown a lot of info about pointers in the literal sense like
int* ptr
.18 replies
Studying singly linked lists and need help understanding pointer functionality
I think I am following. I am guessing that
current
and dummy
are stored in different memory and that's why changing one does not overwrite the other. With dummy
being initialized to a val = 0
from the ListNode constructor, why does dummy not keep that val when creating the chained nodes?18 replies
Studying singly linked lists and need help understanding pointer functionality
I guess what is breaking my brain is the following:
- I set current = dummy (current is now the object dummy instead of just a copy)
- I set current.next = temp (dummy.next now equals temp and so does current.next)
- I set current = temp (why does temp not replace dummy as a whole since setting current.next changes dummy.next?)
18 replies