Connecting Tech Pros Worldwide Forums | Help | Site Map

iterator problem

Axel Gallus
Guest
 
Posts: n/a
#1: Aug 16 '07
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




Obnoxious User
Guest
 
Posts: n/a
#2: Aug 16 '07

re: iterator problem


On Thu, 16 Aug 2007 21:31:29 +0200, Axel Gallus wrote:
Quote:
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'?
Quote:
>
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.

--
Obnoxious User
Closed Thread