Project2_Q2 - #include<iostream>...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<string> #include<fstream> using namespace std; u #define MAX_ITEMS 10 typedef float ItemType; t class SortedList { private: int length; ItemType values[MAX_ITEMS]; int currentPos; public: SortedList(); // default constructor: lenght=0, currentPos=-1 void MakeEmpty(); // let length=0 void InsertItem(ItemType x); // insert x into the list void DeleteItem(ItemType x); // delete x from the list bool IsFull( ); // test if the list is full int LengthIs( ); // return length void RetrieveItem(ItemType x, bool &found); // retrieve x from the list, the // boolean result is stored in found void ResetList( ); // currentPos=-1 void GetNextItem(ItemType &x); // get the next element from the list with // respect to the currentPos }; } SortedList::SortedList() { length = 0; currentPos = -1; } void SortedList::MakeEmpty() { length = 0; } void SortedList::InsertItem(ItemType item) { bool moreToSearch; int location = 0; moreToSearch = (location < length); while(moreToSearch) { if(item < values[location])
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Project2_Q2 - #include&lt;iostream&gt;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online