#include <iostream>
#include <fstream>
#include <string>
#define MAX_ITEMS 10
typedeffloat ItemType;
usingnamespace std;
class SortedList
{
private:
int length;
ItemType values[MAX_ITEMS]; // Static Array
int currentPos;
public:
SortedList() // default constructor: lenght=0, currentPos=-1
{
length = 0;
currentPos = -1;
}
void MakeEmpty() // let length=0
{
length = 0;
}
void InsertItem(ItemType x) // insert x into the list
{
for (int i = 0; i < length; i++)
{
if (values[i] <= x && x < values[i + 1])
{
currentPos = i + 1;
break;
}
}
}
//void DeleteItem(ItemType x); // delete x from the list
bool IsFull(); // test if the list is full
int Lengthls() // return length
{
return length;
}
//void RetrieveItem(ItemType &x, bool &found); // retrieve x from the list, the boolean result is stored in found
void ResetList() // currentPos=-1
{
currentPos = -1;
}
//void GetNextItem(ItemType &x); // get the next element from the list with respect to the currentPos
};
int main()
{
SortedList Instance1;
string line;
ifstream myfile ("float.txt");
if (myfile.is_open())
{
while (getline(myfile, line))
{
Instance1.InsertItem() // i got stuck here.. what to do?
}
myfile.close();
}
else cout << "Unable to open file";
system("Pause");
return 0;
}