In this sub-project, you will implement the class Single_node.
A singly linked node contains two member variables: an element and a pointer to another singly linked node. Figure 1 shows a singly linked list which contains three nodes.
Figure 1. A singly linked list three nodes.
Single_node |
---|
- element:Type - next_node:Single_node |
+ create( in obj:Type = Type(), in n:Single_node = nullptr ):Single_node + retrieve():Type + next():Single_node |
A class which stores an object and a pointer to the next node in a linked list.
The two member variables are:
Single_node( Type const &, Single_node * )
This constructor takes two arguments: a constant reference to an Type (by default, a new instance of the type Type) and a pointer to a Single_node (by default nullptr). These are assigned to the member variables, respectively. (O(1))
This class uses the default destructor.
This class uses the default copy constructor.
This class has two accessors, one to get each of the two associated member variables:
This class has no member functions which modify the member variables.
The classes Single_list<Type>, Cyclic_list<Type>, Sentinel_list<Type>, and Cyclic_sentinel_list<Type> are friends of this class.