iterator problem

A

Axel Gallus

I built a container (without a template), an iterator as a nested class and
a "find"-method:
iterator has a friend relationship with Hash_Map and vice versa.

class Hash_Map

{


iterator find ( value_type ) // Line 6

{

search something.....

return iterator( Param );

}

class iterator : public std:iterator <std::bidirectional_iterator_tag,
value_type, ptrdiff_t, value_type *, value_type &> // Line 16

{

iterator( param_type Param ){ do something } //
constructor

various operators and so on.....

};

}

I get the following error message from VS2005:
"Line 6: std::iterator use of class template requires template argument
list"

If i write Line 6 as
iterator <std::bidirectional_iterator_tag, value_type, ptrdiff_t, value_type
*, value_type &> find ( value_type )
everything compiles fine.

Why do i have to repeat the template instantiation if i already have done
this on line 16 via the inheritance?
All books i read about the STL don't need the template instatiation on Line
6.
Did i domething wrong?


Greetings

A.Gallus
 
O

Obnoxious User

I built a container (without a template), an iterator as a nested class and
a "find"-method:
iterator has a friend relationship with Hash_Map and vice versa.

class Hash_Map

{


iterator find ( value_type ) // Line 6

{

search something.....

return iterator( Param );

}

class iterator : public std:iterator <std::bidirectional_iterator_tag,
value_type, ptrdiff_t, value_type *, value_type &> // Line 16

{

iterator( param_type Param ){ do something } //
constructor

various operators and so on.....

};

}

I get the following error message from VS2005:
"Line 6: std::iterator use of class template requires template argument
list"

Do you think 'std::iterator' is the same as 'HashMap::iterator'?
If i write Line 6 as
iterator <std::bidirectional_iterator_tag, value_type, ptrdiff_t, value_type
*, value_type &> find ( value_type )
everything compiles fine.

Why do i have to repeat the template instantiation if i already have done
this on line 16 via the inheritance?
All books i read about the STL don't need the template instatiation on Line
6.
Did i domething wrong?

Remove the 'using namespace std' and recompile and read the errors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top