this is my coding: Code: const int MAX_LIST=50; typedef ListItemType; class List { public: List(); bool isEmpty() const; int getLength() const; void insert(int index, const ListItemType& newItem,bool& success); void remove(int index, bool& success); void retrieve(int index, ListItemType& dataItem,bool& success) const; private: ListItemType items[MAX_LIST]; int sizr; int translate(int index) const; }; #include "ListA.h" List::List() : size(0) { } bool List::isEmpty() const { return size == 0; } int List::getLength() const { return size; } void List::insert(int index, const ListItemType& newItem, bool& success) { success=(index>=1)&&(index<=size+1)&&(size<MAX_LIST); if(success) { for(int pos=size; pos>=index; --pos) items[translate(pos+1)]=items[translate(pos)]; items[translate(index)]=newItem; ++size; } } void List::remove(int index, bool& success) { success=(index>=1)&&(index<=size); if(success) { for(int fromPosition=index+1; fromPosition<=size;++fromPosition) items[translate(from position-1)]=items[translate(fromPosition)]; --size; } } void List::retrieve(int index, ListItemType& dataItem, bool& success) const { success=(index>=1)&&(index<=size); if(success) dataItem=items[translate(index)]; } int List::translate(int index)const { return index-1; } #include "ListA.h" int main() { List aList; ListItemType dataItem; bool success; aList.insert(1,20,success); aList.remove(1,success); aList.retrieve(1,dataItem,success); int translate(1); return (0); } i get an error during compling. the error shown is:cannot open include file 'ListA.h'.No such file or directory. why??
hi rayda Can you not remove the part where you include the ListA.h file, in this case Code: #include "ListA.h" Or if don't you need the ListA file, create it, I think the header files (.h) are used to define the class and what methods etc it will contain.
true, I think it needs the method definitions or something. edit: here is a nice introduction Introduction to C++ Header Files