D - classes vs structs
- imr1984 (5/5) Jan 16 2004 Im not quite sure how to decide about wether to use a struct or a class ...
- J Anderson (5/11) Jan 16 2004 You probably want to use a struct, because linked lists are meant to be
- Stephan Wienczny (7/26) Jan 16 2004 If he needs one he could have mine...
- imr1984 (3/29) Jan 18 2004 Yeah host it on a website and ill test it. Who knows maybe if its good e...
Im not quite sure how to decide about wether to use a struct or a class for a linked list im making. Each node encapsulates a cvar for a quake like console. The advantages of a class is that i dont need to use pointer syntax, cos everything is by reference anyway. But its gonna be a light weight object so maybe i should use a struct?
Jan 16 2004
imr1984 wrote:Im not quite sure how to decide about wether to use a struct or a class for a linked list im making. Each node encapsulates a cvar for a quake like console. The advantages of a class is that i dont need to use pointer syntax, cos everything is by reference anyway. But its gonna be a light weight object so maybe i should use a struct?You probably want to use a struct, because linked lists are meant to be light weight. But you can encapsulate that in a class. Also you might consider making it a template so you can reuse it. ie instead of having cvar at each node, allow the user to specify anything.
Jan 16 2004
J Anderson wrote:imr1984 wrote:If he needs one he could have mine... I wrote a template linked list ones. It has all basic features... Append, Prepend, Insert, Find etc. As there are no generic foreach's, I had to write Iterators There is only one prob, I did not have much time for testing... StephanIm not quite sure how to decide about wether to use a struct or a class for a linked list im making. Each node encapsulates a cvar for a quake like console. The advantages of a class is that i dont need to use pointer syntax, cos everything is by reference anyway. But its gonna be a light weight object so maybe i should use a struct?You probably want to use a struct, because linked lists are meant to be light weight. But you can encapsulate that in a class. Also you might consider making it a template so you can reuse it. ie instead of having cvar at each node, allow the user to specify anything.
Jan 16 2004
In article <bua7tc$2tvm$1 digitaldaemon.com>, Stephan Wienczny says...J Anderson wrote:Yeah host it on a website and ill test it. Who knows maybe if its good enough it could go into Phobos :)imr1984 wrote:If he needs one he could have mine... I wrote a template linked list ones. It has all basic features... Append, Prepend, Insert, Find etc. As there are no generic foreach's, I had to write Iterators There is only one prob, I did not have much time for testing... StephanIm not quite sure how to decide about wether to use a struct or a class for a linked list im making. Each node encapsulates a cvar for a quake like console. The advantages of a class is that i dont need to use pointer syntax, cos everything is by reference anyway. But its gonna be a light weight object so maybe i should use a struct?You probably want to use a struct, because linked lists are meant to be light weight. But you can encapsulate that in a class. Also you might consider making it a template so you can reuse it. ie instead of having cvar at each node, allow the user to specify anything.
Jan 18 2004