We are being introduced to ADT's with type LIST. I initially thought LIST was included in some C++ library with predefined functions such as .insert(), .retrieve(), .getLength(), isEmpty() and so on. I now suspect this is all created by the programmer with classes and header files........which we'll cover shortly. Confused as usual, this is what I "get" so far:
Grocery list analogy: milk, bread, coffee, rolls
alist.insert(1, milk, success)
alist.insert(2, bread, success)
alist.insert(3, coffee, success)
alist.insert(1, rolls, success) YIELDS:
I have been attempting to understand how to write code to simulate such a list to no avail. I've abandoned that notion for the homework, which asks that we only write on paper with no need to test or compile a C++ function with a parameter ADT List object called "alist." The implementation should consist of calls to other functions of ADT List. We won't directly manipulate any member data????? Assume use of conventional ADT List member functions used in C++ such as insert, remove, getLength etc.
First, "consider" a list of integers and write function that computes the sum of integers in "alist." The function definition must be independent of the list's implementation.
Then I have to write some "swap" function that will reverse the order of some ADT list, but not "write swap()" "just use it!" ?????
I thought that C++ automatically "sums" lists somehow, and that should therefore make it easy to output some sum of some list.......
Thoroughly confused as usual, have brick close to forehead