The answer to it would be situational! If the node class is too big, better cascade it (wrapping). You can always have the complete thing in one class. In this case, there would be a pointer (may be *next) that would be of its own type.
class linked_list;
class linked_list
{
int int_data;
char str[20];
linked_list *next;
public:
<<your_methods>>
};
Hey, Roy -
Thanks for the help. Btw, I noticed that you included an array of 20 char's as possible data to be linked, in addition to integers. I've seen this kind of thing elsewhere ("linking strings of 20 or fewer characters", etc.). Is this a standard? Do linked lists ever hold string of more than 20 characters? Why did you choose 20? Is that a convenction? Is it also a convention to concatenate (hook-up) char's as an array?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.