Lecture 8

We need a way to keep track of how many elements

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ion of List Even the array implementation is not just an array. We need a way to keep track of how many elements there are in the List. An integer variable would do, but if we have several Lists in one program (VERY POSSIBLE!) we need several such integers. THEREFORE... We packaged the integer together with the array as “private” data variables belonging to the instantiated object. 9 const int MAX_LIST = 100; typedef int ItemType; class listClass { public: // constructors, ADT operations private: ItemType Items[MAX_LIST]; int Size; } 10 Create(L) listClass::listClass( ) { Size = 0; // init size } 11 12 Destroy(L) Length(L) int listClass::Length( ) { return Size;...
View Full Document

This document was uploaded on 03/31/2014 for the course CS 114 at NJIT.

Ask a homework question - tutors are online