Sun May 25, 2008 5:14 pm
#include<iostream.h>
typedef int ListElementType;
class List
{
public:
List();
void insert(const ListElementType & elem );
bool first(ListElementType & elem);
bool next(ListElementType & elem);
private:
//implementation specific stuff here
};
#include<iostream.h>
#include"ListADT.h"
List::List()
{
numberOfElements=0;
currentPostion=-1;
}
void List::insert(const ListElementType &elem)
{
assert(numberOfElements<maxListSize);
listArray[numberOfElements]=elem;
numberOfElements++;
}
bool List::first(ListElementType & elem)
{
if (numberOfElements==0)
return false;
else {
currentPostion=0;
elem=listArray[currentPostion];
return true;
}
}
bool List::next(ListElementType &elem)
{
assert(currentPosition>=0)
if(CurrentPosition>=numberOfElements-1)
return false ;
else {
currentPostion--;
elem=listArray[currentPostion];
return true;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.