问题
Ok,
Dumb question time:
Usually with an array I have an object name: object[index] ...and if I have many of them then the index is what distinguishes each object from each other, hopefully, and usually in my case the index has a connection of to the reality of whatever the object is representing so I don't have to go hunting - the third one is the third one...
Now I have a job that requires a linked list as kind of queue (part of an LRU cache) - I just hit a question:
I'm about to declare the first object and add it to the linked list - but what do I call it ?
object ? ...and I have lots of these somehow ?
object1 ? ...if this is the way, then how do I get that '1' there (and then '2' and so on)
I'm guessing the real solution is either really basic and I'll slap myself and/or pointers are involved ?
At the moment I'm just working out the project in terms of major algorithms in pseudoCode and every day go deeper into details. I'm yet to really learn C++ and am coming from a little Java course with and some basic ADT topics, but have no experience in practicalities. Any help really appreciated.
Thanks much!
回答1:
Linked list objects are called nodes, the first one would be head. Yes pointers are involved :) More info http://www.algorithmist.com/index.php/Linked_List
来源:https://stackoverflow.com/questions/13784732/first-time-with-linked-lists-how-do-i-name-objects-for-insertion