I am getting the following when trying to compile the code below:
preallocarray.h: In member function 'void PreallocArray<T>::push_back(const T&)':
preallocarray.h:82: error: expected `;' before 'itr'
I have a nested const_iterator class inside of my LinkedList class I created. It's been many years since I've done C++, so this is probably caused by something silly, but I've been hacking around and googling for an hour with no luck...
Here's my linked list class definition, decared in linklist.h:
template <typename T>
class LinkedList
{
<snip...>
public:
class const_iterator
{
<snip...>
};
<snip...>
};
Then I have a second class, declared in preallocarray.h, as follows:
#include "linklist.h"
template <typename T>
class PreallocArray
{
<snip...>
public:
void push_back( const T & newValue )
{
if (capacity == size)
{
allocateNode( capacity / 2 );
}
LinkedList<Node>::const_iterator itr; // error occurs here
theList.end();
}
<snip...>
private:
LinkedList<Node> theList; // the linked list of nodes
<snip...>
};