I
israphelr
Hi,
I have written a linked list in the same way as I would for C, but
since I am using C++ and not C, i'd like to transform the code into
OOP code.
I have a struct for a node, I am aware that I can use a class,
however, since I am not used to self-referential nodes, I'm a bit
confused, for e.g. I could write a displayNode member function, and
loop through all the nodes from outside the node class, however when
it came to deleting and adding nodes, I would also have to implement
those from outside the node class yes? So i'd have a linked list class
and a node class, and the linked list would contain the code for
handling the nodes (objects).
Some advice on this would be very much appreciated.
Thanks.
I have written a linked list in the same way as I would for C, but
since I am using C++ and not C, i'd like to transform the code into
OOP code.
I have a struct for a node, I am aware that I can use a class,
however, since I am not used to self-referential nodes, I'm a bit
confused, for e.g. I could write a displayNode member function, and
loop through all the nodes from outside the node class, however when
it came to deleting and adding nodes, I would also have to implement
those from outside the node class yes? So i'd have a linked list class
and a node class, and the linked list would contain the code for
handling the nodes (objects).
Some advice on this would be very much appreciated.
Thanks.