473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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<myc lass, D>, std::alloca
tor<myclass> >::iterator' is not a type
x.hpp:154: error: `class std::vector<myc lass, 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 2399
> 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<myc lass, D>, std::alloca
tor<myclass> >::iterator' is not a type
x.hpp:154: error: `class std::vector<myc lass, 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<myc lass>::iterator vit

and then it works...:(

Jul 23 '05 #3
Hi

Try using the typename keyword.

I.E.
template <typename MyClass>
void create(std::vec tor<MyClass>& p_list, typename
std::vector<MyC lass>::iterator p_left, typename
std::vector<MyC lass>::iterator p_right);

std::vector<MyC lass>::iterator can be either a type or a member. The
typename keyword makes it less ambiguous, by telling the compiler that
std::vector<MyC lass>::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.goo glegroups.com.. .
Hi

Try using the typename keyword.

I.E.
template <typename MyClass>
void create(std::vec tor<MyClass>& p_list, typename
std::vector<MyC lass>::iterator p_left, typename
std::vector<MyC lass>::iterator p_right);

std::vector<MyC lass>::iterator can be either a type or a member. The
typename keyword makes it less ambiguous, by telling the compiler that
std::vector<MyC lass>::iterator is a type.

As for algobase.h, try #include <algorithm>

Joe

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7066
by: Stefan Höhne | last post by:
Hi, as I recon, std::vector::clear()'s semantics changed from MS VC++ 6.0 to MS' DOT.NET - compiler. In the 6.0 version the capacity() of the vector did not change with the call to clear(), in DOT.NET the capacity() is reduced to 0.
2
4764
by: Chris Thompson | last post by:
Hi I'm writing a p2p client for an existing protocol. I used a std::vector<char> as a buffer for messages read from the server. The message length is the first 4 bytes. The message code the second 4. The total message length is therefore 4 + message length. A number of messages work fine/as expected but there are consistant errors occuring. After a period
1
1454
by: | last post by:
Say we have a vector defined as std::vector <TMyClass> MyVector; and we appended N number of element (N>1) to our vector (ie. MyVector.size() is N) How can we remove/delete an individual element MyVector (where 0<i<N) in such a way that after the remove/delete operation MyVector.size() will be N-1 ?
20
17812
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; std::vector<double>::size_type size = src.size(); dest.reserve(size); for (std::vector<int>::size_type i = 0;
9
8894
by: aaragon | last post by:
I am trying to create a vector of type T and everything goes fine until I try to iterate over it. For some reason, the compiler gives me an error when I declare std::vector<T>::iterator iter; Any ideas why is tihs happening? The code is as follows: template <class T> struct StdVectorStorage { std::vector<T>* _storage;
8
5359
by: Lionel B | last post by:
On my platform I find that the std::vector<boolspecialisation incurs a significant performance hit in some circumstances (when compared, say, to std::vector<intprogrammed analagously). Is it possible to "spoof" std::vector into implementing a "true" vector of bool rather than the specialisation? Say I do: typedef bool boolreally; std::vector<booleallybvec;
4
20039
by: Bobrick | last post by:
Hi. I'm in the process of making a GUI for a function someone else wrote, and i've come across a type i'm unfamiliar with, namely "std::vector<unsigned char>". I need to get the contents of this variable into a form I can display in a text box, but i'm not sure what to expect inside of the variable, whether I can just treat it like an array e.t.c. Any help would be appreciated. Thanks,
8
3608
by: jacek.dziedzic | last post by:
Hi! I need to be able to track memory usage in a medium-sized application I'm developing. The only significant (memory-wise) non- local objects are of two types -- std::vector<and of a custom class simple_vector<that is a hand-rolled substitute for array<>. With the latter I have code that tracks all allocations and destructions, so I can account for all the memory. The question is about std::vector<-- how can I track memory usage
3
5636
by: Rune Allnor | last post by:
Hi folks. I have a function that takes an element in a vector as argument. The naive interface goes as float computeSomething(const std::vector<float>& v, size_t i) { size_t j = i-1; size_t k = i+1;
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.