Connecting Tech Pros Worldwide Help | Site Map

whatz wrong in std::vector< myclass >::iterator

  #1  
Old July 23rd, 2005, 06:49 AM
John
Guest
 
Posts: n/a
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

  #2  
Old July 23rd, 2005, 06:49 AM
Stephen Howe
Guest
 
Posts: n/a

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


  #3  
Old July 23rd, 2005, 06:49 AM
John
Guest
 
Posts: n/a

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

  #4  
Old July 23rd, 2005, 06:49 AM
joe.els@dariel.co.za
Guest
 
Posts: n/a

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

  #5  
Old July 23rd, 2005, 06:50 AM
benben
Guest
 
Posts: n/a

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]


Closed Thread