== Part 1: Integer Linked List ==
For this part, you will build the classes '''IntList ''' and '''IntListNode ''' in the files '''intlist.h ''' and '''intlist.cpp '''. These two classes compose a basic implementation of an integer linked list . Please see the following sections on the exact specifications of these classes.
=== Class: IntListNode, Files: [intlist.h, intlist.cpp], Test: 0 ===
An IntListNode is an integer linked list node , as such it holds an integer value and a pointer to an IntListNode that is the next node in the list . If the next link is NULL then the current node is considered the '''last node in the list'''. <br/>Note that the next property of this class has a public getter and a protected setter; this is intentional as client code should not mess with the '''structure''' of our linked list. <br/>While this class is only used by IntList , it is expected to have a set of its own functionality.
It is expected that the '''class declaration''' for this class lie in '''intlist.h''' and the definition code lie in '''intlist.cpp'''. In most implementations, you will need to make the class '''IntList''' a friend of this class to access the protected '''next setter'''. The exact specs follow: ==== Internal Variables ==== Please note that the names provided in all '''Internal Variables''' sections are suggested but '''not mandatory''' . ; int _val: Held integer value. ; IntListNode* _next: Pointer to the next node in the list.
==== Protected Functions ====
void next (IntListNode*): Next setter. Sets the internally held next pointer to the incoming pointer.
==== Public Functions ====
IntListNode(int v = int(), IntListNode* n = NULL): Constructor. Note the default values. Initializes the internally held value to v and the next pointer to n.; IntListNode(const IntListNode& src): Copy constructor. Should initialize the internally held value to src's internally held value. Should initialize '''next ''' to '''NULL '''.; IntListNode& operator=(const IntListNode& src): Assignment operator. Should set the internally held value to src's internally held value. Should set '''next ''' to '''NULL '''. Should do '''NOTHING''' in the case of '''self-assignment ''' (ie IntListNode x; x = x;). Returns a reference to the current object . ; ~IntListNode(): Destructor. As this node does not allocate any memory, this function can remain empty.
int val () const: Val getter. Returns the value internally held.; void val (int): Val setter. Sets the internally held value to the incoming value.
IntListNode* next () const: Next getter. Returns the internally held next pointer.
=== Class: IntList, Files [intlist.h, intlist.cpp], Test: 0 ===