iterator problem



 DEVELOP > c-Plus-Plus > iterator problem

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Axel Gallus"
Date: 16 Aug 2007 02:31:29 PM
Object: iterator problem
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
.

User: "Obnoxious User"

Title: Re: iterator problem 16 Aug 2007 03:18:11 PM
On Thu, 16 Aug 2007 21:31:29 +0200, Axel Gallus wrote:

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.
--
Obnoxious User
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER