Skip to main content
gamedev.net
🔒 Locked

Class[X] = OtherClass;

Started by Sand_Hawk 4 replies 250+ views
Original Post
Sand_Hawk
Sand_Hawk
Here I am again with more questions. I have 2 classes, a CLinked and a CNode. CNode contains the data and CLinked holds the list. I changed an certain item in CNode and want to put it back in CLinked. How can I do this:
CLinked[Index] = CNode;
 
I CLinked I have the [] operator overloaded and in CNode the = operator. Can I now use the above code or will it fail and how I can get it straight? Sand Hawk ---------------- -Earth is 98% full. Please delete anybody you can.
My Site
----------------(Inspired by Pouya)
Sand_Hawk
Sand_Hawk
Well, I should take a look into the STL, however, I need to write my own linked list class for school. And probably I will use this one instead of the STL in my games. Anyway, writing your own Linked List is as important as knowing/understanding STL.

[EDIT]
Whoops, I didn't read the reply complete well. It should return a MUTABLE reference. So CNode& . And when there is nothing to return, just return NULL.
[/EDIT]

Sand Hawk

----------------
-Earth is 98% full. Please delete anybody you can.


My Site


[edited by - sand_hawk on October 23, 2002 3:38:48 PM]
----------------(Inspired by Pouya)
Basiror
Basiror
erm you create extra classes to create linked lists?
oh god
just create a classname *next;
classname *prev; pointer set it to NULL in your constructor and create a function that add a passed class to your list
i hate these template classes for linked lists in my opinion they are a waste of memory
http://www.8ung.at/basiror/theironcross.html
Sand_Hawk
Sand_Hawk
Basiror, I use a classed because it was specified in the assignment. i have my almost finished the templated version. Templates are good since you write it only once, instead of the C way, where you have to write for each type a new list.

Sand Hawk

----------------
-Earth is 98% full. Please delete anybody you can.


My Site
----------------(Inspired by Pouya)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.