its about the lists sorted or unsorted

list.cpp

#include "list.h"
#include<iostream>

using namespace std;

int list::length()const
{


return length;
}

bool list::isfull()const
{
return (length == max_length);

}
list::list()
{
length = 0;
}
void list::insert(itemtype item)
{
data[length] = item;
length++;
}
bool list::isempty()const
{
return(length == 0);

}
bool list::ispresent(itemtype item) const
{
int index = 0;
while (index < length && item != data[index])
index++;
return (index < length);

}
void list::Delete(itemtype item)
{
int index = 0;
while (index < length && item != data[index)
index++;
if (index < length)
{
data[index] = data[length - 1];
length--;

}
}
void list::reset()
{
int currentpos;
currentpos = 0;


}
itemtype getnextitem()
{
itemtype item;
item = data[currentpos];
if (currentpos == (length - 1)){

currentpos = 0;
}
else
currentpos++;
return item;
}
void list::selsort()
{
itemtype temp;
int passcount;
int sindex;
int minindex;

for (passcount = 0; passcount < length - 1; passcount++)
{
minindex = passcount;
for (sindex = passcount + 1; sindex < length; sindex++)
if (data[sindex] == data[minindex])
minindex = sindex;
temp = data[minindex];

}
}

void list::print(){
cout << "------------------------------------------" << endl;

for (int i = 0; i < length; i++){
cout << data[i] << endl;

}



cout << "------------------------------------------" << endl;

}







list.h

#include<iostream>
#include<string>

using namespace std;

const int max_length = 50;
typedef string itemtype;

class list{
public:
list();
bool isempty() const;
bool isfull() const;
int length();
void insert(itemtype item);
void Delete(itemtype item);
bool ispresent(itemtype item) const;
void selsort();
void reset();
itemtype getnextitem();

void print();

private:
int length;
itemtype data[max_length];
int curentpos;



};


main.cpp

#include<iostream>
#include<string>
#include<fstream>
#include "list.h"

using namespace std;


int main(){
cout << "Hello World!!!" << endl;
string words;
ifstream infile;
infile.open("words.txt");
while (!infile.eof()){
infile >> words;
cout << "words are " << words << endl;
}
list list;
list.insert("Bluejay");
list.print();

list.insert("Dove");
list.print();




return 0;
}



// I dont know where i am wrong need help with this
Topic archived. No new replies allowed.