Open main menu

CDOT Wiki β

Changes

Project A3 20141 - OOP344

503 bytes removed, 02:26, 23 March 2014
Class: ListNode, Files: [list.h], Test: 1: Finished ListNode
'''NOTE:''' The function signature for ListNode::val setter and List::push are different from their IntListNode::val setter and IntList::push counterparts!
=== Class: ListNode<T>, Files: [list.h], Test: 1 ===An IntListNode is an integer linked list node, as such it holds an integer value and a pointer Templated ListNode class. Similar 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 but templated to have a set of its own functionalityhold any type.
It is expected that the '''class declaration''' for this class lie in and '''intlist.hdefinition''' and the definition code lie in '''intlistlist.cpph'''.
In most implementations, you will need to make the class '''IntListList<T>''' a friend of this class to access the protected '''next setter'''.
'''TIP:''' The syntax for prototyping a templated class is: template <typename T> SomeClass; The exact specs followand assume that the template:
==== Internal Variables ====
Please note that the names provided in all '''Internal Variables''' sections are suggested but '''not mandatory'''. ; int T _val: Held integer value.; IntListNodeListNode<T>* _next: Pointer to the next node in the list.
==== Protected Functions ====
; void next(IntListNodeListNode<T>*): Next setter. Sets the internally held next pointer to the incoming pointer.
==== Public Functions ====
; IntListNodeListNode(int const T& v = intT(), IntListNodeListNode<T>* n = NULL): Constructor. Note the default values. Initializes the internally held value to v and the next pointer to n.; IntListNodeListNode(const IntListNodeListNode<T>& src): Copy constructor. Should initialize the internally held value to src's internally held value. Should initialize '''next''' to '''NULL'''.; IntListNodeListNode& operator=(const IntListNodeListNode<T>& 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 ListNode<T> x; x = x;). Returns a reference to the current object.; ~IntListNodeListNode(): Destructor. As this node does not allocate any memory, this function can remain empty.
; int T val() const: Val getter. Returns the value internally held.; void val(intconst T&): Val setter. Sets the internally held value to the incoming value.
; IntListNodeListNode<T>* next() const: Next getter. Returns the internally held next pointer.
=== Class: IntList, Files [intlist.h, intlist.cpp], Test: 0 ===