My function prototype looks as follows:
// Purpose: finds an element in the ArrayList
// Parameters: 'x' is value to be found in the ArrayList
// Returns: the position of the first occurrance of 'x' in the list, or -1 if 'x' is not found.
int find(const T& x) const;
It is placed in the class ArrayList
template <typename T>
class ArrayList
{
private:
int m_size; // current number of elements
int m_max; // maximum capacity of array m_data
T* m_data; // array to store the elements
T m_errobj; // dummy object to return in case of error
public:
int find(const T& x) const;
My definition is:
template <typename T>
int find(const T& x) const
{
int i;
while (m_data[i]!=x && m_data[i]!=NULL)
i++;
if (m_data[i]=x)
return i;
else
return (-1);
}
Whenever I compile, I receive the error in the title, and an error that m_data is not declared in the scope. How do I fix this?
Edit: I changed the definition to
int ArrayList<T>:: find(const T& x) const
I got a ton of errors
int ArrayList:: find(const T& x) const
didn't work either