template <class elemType>
void ArrayList<elemType>::print()const
{
for(int i = 0; i < length; i++)
cout<<list[i]<<" ";
cout<<endl;
}
template <class elemType>
void ArrayList<elemType>::insertAt
(int location, const elemType& insertItem)
{
if(location < 0 || location >= maxSize)
cerr<<"The position of the item to be inserted "
<<"is out of range."<<endl;
else
if(length >= maxSize) //list is full
cerr<<"Cannot insert in a full list"<<endl;
else
{
for(int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at the
//specified position
length++; //increment the length
}
} //end insertAt
template <class elemType>
void ArrayList<elemType>::insertEnd(const elemType& insertItem)
{
if(length >= maxSize) //the list is full
cerr<<"Cannot insert in a full list."<<endl;
else
{
list[length] = insertItem; //insert the item at the end
length++; //increment length
}
} //end insertEnd
template <class elemType>
void ArrayList<elemType>::RemoveAt(int location)
{
if(location < 0 || location >= length)
cerr<<"The location of the item to be removed "
<<"is out of range."<<endl;
else
{
for(int i = location; i < length - 1; i++)
list[i] = list[i+1];
template <class elemType>
void ArrayList<elemType>::insert(const elemType& insertItem)
{
int loc;
if(length == 0) //list is empty
list[length++] = insertItem; //insert the item and
//increment the length
else
if(length == maxSize)
cout<<"Cannot insert in a full list."<<endl;
else
{
loc = seqSearch(insertItem);
if(loc == -1) //the item to be inserted
//does not exist in the list
list[length++] = insertItem;
else
cerr<<"the item to be inserted is already in "
<<"the list. No duplicates are allowed."<<endl;
}
} //end insert
template <class elemType>
void ArrayList<elemType>::Remove(const elemType& removeItem)
{
int loc;
if(length == 0)
cerr<<"Cannot delete from an empty list."<<endl;
else
{
loc = seqSearch(removeItem);
if(loc != -1)
RemoveAt(loc);
else
cout<<"The tem to be deleted is not in the list."
<<endl;
}
} //end remove
template <class elemType>
ArrayList<elemType>::ArrayList(int size)
{
if(size < 0)
{
cerr<<"The array size must be positive. Creating "
<<"an array of size 100. "<<endl;
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new elemType[maxSize];
assert(list != NULL);
}
}
when I try to implement an object I get this message:
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ArrayList<char>::ArrayList<char>(int)" (??0?$ArrayList@D@@QAE@H@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall ArrayList<char>::~ArrayList<char>(void)" (??1?$ArrayList@D@@QAE@XZ) referenced in function _main
1>C:\Users\shahid\documents\visual studio 2012\Projects\ArrayList\Debug\ArrayList.exe : fatal error LNK1120: 2 unresolved externals