469,933 Members | 2,386 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,933 developers. It's quick & easy.

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

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

Jul 23 '05 #1
4 2228
> 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
Does x.hpp include <vector> ?
I am trying to port some old code to a new machine. Also what happened
to algobase.h?


No such thing. You might want <algorithm>

Stephen Howe
Jul 23 '05 #2
yes it does include <vector>

I corrected the problem by using

typedef typename std::vector<myclass>::iterator vit

and then it works...:(

Jul 23 '05 #3
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

Jul 23 '05 #4
The OP didn't come up with a template so there's no need to use a typedef

ben

<jo*****@dariel.co.za> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Stefan Höhne | last post: by
2 posts views Thread by Chris Thompson | last post: by
9 posts views Thread by aaragon | last post: by
4 posts views Thread by Bobrick | last post: by
8 posts views Thread by jacek.dziedzic | last post: by
3 posts views Thread by Rune Allnor | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.