#ifndef DynList_H_2011
#define DynList_H_2011
constint DEFAULT_MAXLENGTH = 10000;
template<class ItemType>
class DynList
{
public:
//constructor
DynList();
//Destructor
~DynList();
//Action Responsibilities
bool Insert(ItemType item);
//Adds Item to List and increments length
void Delete(ItemType item);
//Item is removed from list
void ResetList();
//current pos is reset to first item
ItemType GetNextItem();
//HasNext must be true
//Knowledge Responsibilities
int GetLength() const;
//returns listlength
bool IsEmpty() const;
//true if list is empty
bool IsThere(ItemType item) const;
//checks to see if item is in list
bool HasNext() const;
//checks to see if there is a next item
int RoomLeft() const;
private:
ItemType* itArr = new ItemType[DEFAULT_MAXLENGTH];
int length;
int currentPos;
};
#endif // DynList_H
#include <iostream>
#include <cstdlib>
#include "DynList.h"
#include "DynList.cpp" // I know this is weird, but it kept telling me my functions were undefined until I did this. crude, but it works.
usingnamespace std;
int main()
{
DynList<int> intArray;
DynList<double> doubArray;
int x = 11;
for (int i = 0; i < 100; i++)
{
x+=6;
intArray.Insert(x);
}
double y = 11.11;
for (int i = 0; i < 100; i++)
{
y+= 6.66;
doubArray.Insert(y); }
cout << intArray.GetNextItem();
}