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

|
Related Articles |
|
|