I'm trying to get an example from a book to work and im getting this error in 1 of the 3 files
.h
#ifndef H_unorderedArrayListType
#define H_unorderedArrayListType
template <class elemType>
class unorderedArrayListType
{
public:
void insertAt(int location, const elemType& insertItem);
void insertEnd(const elemType& insertitem);
void replaceAt(int location, const elemType& repitem);
void retrieveAt(int location, const elemType& repitem);
int seqSearch(const elemType& searchItem) const;
void remove(const elemType& removeItem);
void sort();
int binSearch(const elemType& item) const;
unorderedArrayListType(int size = 100);
};
#endif
.cpp
#include "unorderedArrayListType.h"
template <class elemType>
int unorderedArrayListType<elemType>::binSearch(const elemType& item) const
{
return binarySearch(list, length, item);
}
template <class elemType>
void unorderedArrayListType<elemType>::sort()
{
selectionSort(list, length);
}
unorderedArrayListType::binSearch(const elemType&) const'
6 error: 'list' was not declared in this scope
6 error: 'length' was not declared in this scope
In member function 'void unorderedArrayListType::sort()':
12 error: 'list' was not declared in this scope
12 error: 'length' was not declared in this scope
12 error: there are no arguments to 'selectionSort' that depend on a template parameter, so a declaration of 'selectionSort' must be available [-fpermissive]
12 note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
|=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
list
, but you haven't declared it anywhere. Could be a mistake in the book, or you missed something. – The Darkcpp
file. It wont work. The second thing is thatlist
andlength
just don't seem to be defined anywhere. Should they possibly be member variables? – pmr