Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 05:49 AM
John
Guest
 
Posts: n/a
Default 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


  #2  
Old July 23rd, 2005, 05:49 AM
Stephen Howe
Guest
 
Posts: n/a
Default 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, 05:49 AM
John
Guest
 
Posts: n/a
Default 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, 05:49 AM
joe.els@dariel.co.za
Guest
 
Posts: n/a
Default 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, 05:50 AM
benben
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

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 220,840 network members.