Jump to: navigation, search

Project A3 20141 - OOP344

802 bytes removed, 08:56, 3 April 2014
Part 2: Templated Linked List: Partial update
== Part 2: Templated Linked List ==
'''NOTE: Do NOT start ''' Finish part 1 before working on this part before finishing part 1 and making sure that it passes all tests!'''.
For this part, you will build Build the classes '''Listtemplated linked list node class ListNode<T>''' and '''ListNode''' in the file '''list.h'''. These two classes compose a templated linked list. A lot of the code for these classes is '''very similar''' to the code you already wrote for the IntListNode and IntList classes, except that the code is now templated. Therefore, it is suggested that you '''copy''' the code that you wrote for those classes and '''paste''' it into class List<T> in the file list.h file, updating the references to IntListNode and IntList and generally adjusting the code as required.
These two classes are almost identical to IntListNode and IntList, except that they are templated. In the specs below, note the sections that are marked '''NOTE:Important''' The function signature for ListNode::ListNode, ListNode::val setter, and List::push are different . Those sections will have more than just a template parameter change from their IntListNode and IntList counterparts!the int version of the list.
=== Class: ListNode<T>, Files: [list.h], Test: 1 ===
Templated ListNode class. Similar to IntListNode but templated to hold any type.
It is expected that '''class declaration''' and '''definition''' lie in '''list.h'''. In most implementations, you will need to make the class '''List<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 follow and assume that the template: ==== Internal Variables Recommended Members ====; T _val: Held * Template type member to hold the value.; ListNode<T>* _next: Pointer to the next node in the list. ==== Protected Functions ====; void next(ListNode<T>*): Next setter. Sets the internally held next pointer to the incoming pointer.
==== Public Functions ====

Navigation menu