whatz wrong in std::vector< myclass >::iterator 
July 23rd, 2005, 06:49 AM
| | | |
I have a function declaration that gives an error while compiling.
Can anyone help me figure this one out?
inline void create(const std::vector< myclass >& plist,
std::vector< myclass >::iterator
left,
std::vector< myclass >::iterator
right);
x.hpp:153: error: `class std::vector<myclass, D>, std::alloca
tor<myclass> >::iterator' is not a type
x.hpp:154: error: `class std::vector<myclass, std::alloca
tor<myclass> >::iterator' is not a type
x.hpp:154: error: ISO C++ forbids declaration of `left' with no type
x.hpp:154: error: ISO C++ forbids declaration of `right' with no type
I am trying to port some old code to a new machine. Also what happened
to algobase.h?
Thanks,
--j | 
July 23rd, 2005, 06:49 AM
| | | | re: whatz wrong in std::vector< myclass >::iterator
> inline void create(const std::vector< myclass >& plist,[color=blue]
> std::vector< myclass >::iterator
> left,
> std::vector< myclass >::iterator
> right);
>
> x.hpp:153: error: `class std::vector<myclass, D>, std::alloca
> tor<myclass> >::iterator' is not a type
> x.hpp:154: error: `class std::vector<myclass, std::alloca
> tor<myclass> >::iterator' is not a type
> x.hpp:154: error: ISO C++ forbids declaration of `left' with no type
> x.hpp:154: error: ISO C++ forbids declaration of `right' with no type[/color]
Does x.hpp include <vector> ?
[color=blue]
> I am trying to port some old code to a new machine. Also what happened
> to algobase.h?[/color]
No such thing. You might want <algorithm>
Stephen Howe | 
July 23rd, 2005, 06:49 AM
| | | | re: whatz wrong in std::vector< myclass >::iterator
yes it does include <vector>
I corrected the problem by using
typedef typename std::vector<myclass>::iterator vit
and then it works...:( | 
July 23rd, 2005, 06:49 AM
| | | | re: whatz wrong in std::vector< myclass >::iterator
Hi
Try using the typename keyword.
I.E.
template <typename MyClass>
void create(std::vector<MyClass>& p_list, typename
std::vector<MyClass>::iterator p_left, typename
std::vector<MyClass>::iterator p_right);
std::vector<MyClass>::iterator can be either a type or a member. The
typename keyword makes it less ambiguous, by telling the compiler that
std::vector<MyClass>::iterator is a type.
As for algobase.h, try #include <algorithm>
Joe | 
July 23rd, 2005, 06:50 AM
| | | | re: whatz wrong in std::vector< myclass >::iterator
The OP didn't come up with a template so there's no need to use a typedef
ben
<joe.els@dariel.co.za> wrote in message
news:1120449952.691290.111970@g44g2000cwa.googlegr oups.com...[color=blue]
> Hi
>
> Try using the typename keyword.
>
> I.E.
> template <typename MyClass>
> void create(std::vector<MyClass>& p_list, typename
> std::vector<MyClass>::iterator p_left, typename
> std::vector<MyClass>::iterator p_right);
>
> std::vector<MyClass>::iterator can be either a type or a member. The
> typename keyword makes it less ambiguous, by telling the compiler that
> std::vector<MyClass>::iterator is a type.
>
> As for algobase.h, try #include <algorithm>
>
> Joe
>[/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|