Sizei collectioni srccollectioni srccollectioni w

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: our W hat if we want a collection of something other What than int. int IntIndColl::IntIndColl(const IntIndColl& src) src { size = src.size; size src.size collection = new int[size]; // new space collection int[size for (int i=0;i<src.size;i++) collection[i] = src.collection[i]; src.collection[i } W e could create a FloatIndColl.h (& .cpp) We FloatIndColl.h (& by going through the code and replacing the type. by Or we could just make a templated class. Or templated An assignment operator can also be incorporated An in the ADT. in Applied Programming class IntIndColl class IntIndColl { public: IntIndColl(int sz = 100); ~IntIndColl(); void Store(int,int); void Store(int,int int Retrieve(int) const; void Copy(const IntIndColl&); void Copy(const private: int *collection; int size; }; Applied Programming Applied Programming class IntIndColl class IntIndColl { public: IntIndColl(int sz = 100); ~IntIndColl(); void Store(int,int); void Store(int, int Retrieve(int) const; void Copy(const IntIndColl&); void Copy(const private: int *collection; int size; }; Applied Programming template <class T> template class IntIndColl class IntIndColl { public: IntIndColl(int sz = 100); ~IntIndColl(); void Store(int,T); void Store(int, T Retrieve(int) const; void Copy(const IntIndColl&); void Copy(const private: T *collection; int size; }; template <class T> class IntIndColl class IntIndColl { public: IntIndColl(int sz = 100); ~IntIndColl(); void Store(int,T); void Store(int,T T& Retrieve(int) const; T& Retrieve(int void Copy(const IntIndColl&); void Copy(const private: T *collection; int size; }; Applied Programming Applied Programming The Generalised Linked List How do we then get an instance? IndColl<Video> videoarr(vsize); <Video> videoarr(vsize W hat we've called a linked list so far is actually a What data structure called a queue, where items are always added to the end of the list and always taken from the front of the list. (FIFO) taken You will learn all about You template classes in CSCI...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online