Expected initializer before 'Iterator'

The code is like this:

in .impl file, function definition

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template<class ElemType>
typename DoublyLinkedList<ElemType>::Iterator Iterator
Iterator DoublyLinkedList<ElemType>::search(const ElemType& target)
{
	DoublyLinkedListNode* loop = m_head->m_next;
	DoublyLinkedList<ElemType>::Iterator it;
	while(loop != m_head){
		if(loop->element = target){
			it = loop;
			return it;
		}
	}
	it = m_head;
	return it;
}


The compiler complains that "Expected initializer before 'Iterator'",I don't know what is missing/going wrong.
Last edited on
Why is the word "Iterator" repeated 3 times in a row at line 2-3?
Why do you make typename DoubleLinkedList<ElemType>::Iterator Iterator and don't use it?

anyway, you need to write typename before an Iterator when using templates.
typename DoublyLinkedList<ElemType>::Iterator it;
Topic archived. No new replies allowed.