When creating a node for a linked list it might look something like this:
template <class T>
class node {
T data;
node* next;
}
for a doubly linked list it might look something like this:
template <class T>
class node {
T data;
node* next;
node* prev;
}
and for a BST it might look something like this:
template <class T>
class node {
T data;
node* left_child;
node* right_child;
}
this can all be generalized in the following format:
template <class T>
class node {
T data;
node* links[N]; // N = 1 for linked list, N = 2 for tree or doubly linked list, etc...
}
What is the best way to specify N in the class ctor without using STL vectors?
How about
and use it as:
I however think it’s too complicated, and should keep it as you had it originally. Much cleaner.