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

J

John

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
 
S

Stephen Howe

inline void create(const std::vector said:
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 said:
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
 
J

John

yes it does include <vector>

I corrected the problem by using

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

and then it works...:(
 
J

joe.els

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top