How do I bring STL iterators into the current scope? eg.
#include <vector>
using std::vector;
int main()
{
vector<int>::iterator it;
return 0;
}
gives an error 9 7815
onion_skin wrote: How do I bring STL iterators into the current scope? eg.
#include <vector> using std::vector;
int main() { vector<int>::iterator it;
return 0; }
gives an error
What error, and on what compiler? I tried the above on a few different
compilers with no errors. Comeau's online test also compiles it, albeit
with a warning that 'variable "it" is declared but never referenced'.
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
On Wed, 25 Jun 2003 11:06:12 -0400, "Victor Bazarov"
<v.********@attAbi.com> wrote: "onion_skin" <on************@travers.com> wrote... How do I bring STL iterators into the current scope? eg.
#include <vector> using std::vector;
int main() { vector<int>::iterator it;
return 0; }
gives an error
What error? The code is legal C++ and compiles fine here. Perhaps the compiler you're using is not good enough? If that's so, try adding 'using namespace std;' in the scope of the 'main' function.
Victor
MSVC6.0 gives the error:
"error C2653: 'vector<int,class std::allocator<int> >' : is not a
class or namespace name"
I don't want to use expose the entire library by using 'using
namespace std' (although that, obviously, works)
onion_skin wrote: On Wed, 25 Jun 2003 11:06:12 -0400, "Victor Bazarov" <v.********@attAbi.com> wrote:
<snip> What error? The code is legal C++ and compiles fine here. Perhaps the compiler you're using is not good enough? If that's so, try adding 'using namespace std;' in the scope of the 'main' function.
Victor
MSVC6.0 gives the error:
"error C2653: 'vector<int,class std::allocator<int> >' : is not a class or namespace name"
That's interesting. Worked fine on VC++ 6.0 when I tried it. Are you
sure you posted enough code to replicate the problem?
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
"Corey Murtagh" <em***@slingshot.co.nz.no.uce> wrote... onion_skin wrote:
On Wed, 25 Jun 2003 11:06:12 -0400, "Victor Bazarov" <v.********@attAbi.com> wrote: <snip> What error? The code is legal C++ and compiles fine here. Perhaps the compiler you're using is not good enough? If that's so, try adding 'using namespace std;' in the scope of the 'main' function.
Victor
MSVC6.0 gives the error:
"error C2653: 'vector<int,class std::allocator<int> >' : is not a class or namespace name"
That's interesting. Worked fine on VC++ 6.0 when I tried it.
Are you sure? It didn't when I tried it on VC++ v6.0 sp5.
Are you sure you posted enough code to replicate the problem?
Are you sure _you_ tried the right code?
---------------------------------------------
#include <vector>
using std::vector;
int main()
{
vector<int>::iterator it;
return 0;
}
---------------------------------------------
Victor
Also compiles without error or warning, using MS Compiler 7.1 (now 97% C++
compliant)
Regards,
Tom
"onion_skin" <on************@travers.com> wrote in message
news:9g********************************@4ax.com... How do I bring STL iterators into the current scope? eg.
#include <vector> using std::vector;
int main() { vector<int>::iterator it;
return 0; }
gives an error
Victor Bazarov wrote: "Corey Murtagh" <em***@slingshot.co.nz.no.uce> wrote...
<snip> That's interesting. Worked fine on VC++ 6.0 when I tried it.
Are you sure? It didn't when I tried it on VC++ v6.0 sp5.
Are you sure you posted enough code to replicate the problem?
Are you sure _you_ tried the right code?
eep... ok, I messed up. Sorry. I guess all those months of typing
'std::' in front of every STL object has gone to my brain.
On the upside, I can confirm that it *does* work on the following compilers:
BCB4
Dev-C++/MinGW32 v2.95.3-6
g++ v2.95.4
Also works on Comeau's online test :)
One work-around for VC++ 6.0:
---------------
#include <vector>
#define vector std::vector
int main()
{
vector<int>::iterator it;
return 0;
}
---------------
Of course this can cause all sorts of problems, but it does appear to
work in this specific case.
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
On Wed, 25 Jun 2003 11:44:53 -0400, "Victor Bazarov"
<v.********@attAbi.com> wrote: "Corey Murtagh" <em***@slingshot.co.nz.no.uce> wrote... onion_skin wrote:
> On Wed, 25 Jun 2003 11:06:12 -0400, "Victor Bazarov" > <v.********@attAbi.com> wrote: <snip> >> >>What error? The code is legal C++ and compiles fine here. >>Perhaps the compiler you're using is not good enough? If >>that's so, try adding 'using namespace std;' in the scope >>of the 'main' function. >> >>Victor >> > > > MSVC6.0 gives the error: > > "error C2653: 'vector<int,class std::allocator<int> >' : is not a > class or namespace name"
That's interesting. Worked fine on VC++ 6.0 when I tried it.
Are you sure? It didn't when I tried it on VC++ v6.0 sp5.
Are you sure you posted enough code to replicate the problem?
Are you sure _you_ tried the right code? --------------------------------------------- #include <vector>
using std::vector;
int main() { vector<int>::iterator it; return 0; } ---------------------------------------------
Victor
This is the code
-------------------------------------------
#include <vector>
using std::vector;
int main()
{
vector<int>::iterator it;
return 0;
}
-------------------------------------------
"Tom" <to*@yahoo.com> wrote in message
news:bd************@ID-133116.news.dfncis.de... Also compiles without error or warning, using MS Compiler 7.1 (now 97% C++ compliant)
Regards, Tom
Where do you get 7.1 from? I'm on 7.0.9466 and I reckon I'm only 96%
complaint.
john
Corey Murtagh <em***@slingshot.co.nz.no.uce> wrote in message news:<10***************@radsrv1.tranzpeer.net>... Victor Bazarov wrote:
"Corey Murtagh" <em***@slingshot.co.nz.no.uce> wrote... <snip> That's interesting. Worked fine on VC++ 6.0 when I tried it.
Are you sure? It didn't when I tried it on VC++ v6.0 sp5.
Are you sure you posted enough code to replicate the problem?
Are you sure _you_ tried the right code?
eep... ok, I messed up. Sorry. I guess all those months of typing 'std::' in front of every STL object has gone to my brain.
On the upside, I can confirm that it *does* work on the following compilers:
BCB4 Dev-C++/MinGW32 v2.95.3-6 g++ v2.95.4
Also works on Comeau's online test :)
One work-around for VC++ 6.0:
--------------- #include <vector> #define vector std::vector
int main() { vector<int>::iterator it;
return 0; } ---------------
Of course this can cause all sorts of problems, but it does appear to work in this specific case.
A better (because it doesn't use a macro, buit still irritating
because it shouldn't be necessary at all) work-around for VC++ 6.0:
#include <vector>
int main()
{
std::vector<int>::iterator it;
return 0;
}
This VC++ 6.0 feature has got me into the habit of using fully
qualified names in preference to using declarations.
GJD This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Talha |
last post by:
Hi,
I have a general question about iterators
suppose I have a class
class MyClass
{
public:
....
|
by: Jim West |
last post by:
I'm curious why I might be getting such a large performance
difference between using a map iterator and a vector iterator.
This is a computational electromagnetics code where I have to
separate...
|
by: Sanyi |
last post by:
Hello,
I've did some some numerical programs in C/C++ before, but decided to use
STL to write neater code. Then again I don't want to give up speed so I have
a couple of questions. Apparently...
|
by: Anirudh Ramachandran |
last post by:
Hi all,
I have a homework problem here, where I have to perform a set
intersection on two sets and use the result elsewhere. I have this
code:
#include <iostream>
#include <iterator>...
|
by: fastback66 |
last post by:
Evidently per the C++ standard, it is not possible to measure the
distance between two stream iterators, because two non-end-of-stream
iterators are equal when they are constructed from the same...
|
by: John |
last post by:
In STL's map implementation, the distance between two
iterators it1, it2 takes O(K) to compute where K is the
actual distance between the two iterators.
In theory, a red black tree can do this...
|
by: Thomas Grund |
last post by:
Hi,
If I store an iterator to a std::vector and then push_back some elements
then the iterator is not valid anymore since the internal data of the
vector is reallocated.
Can I store an...
|
by: Rennie deGraaf |
last post by:
Hello,
I would like to write a function that reads a sequence of unsigned
shorts from /any/ container, converts them to pairs of unsigned chars,
and writes them to /any/ container. In other...
|
by: prasadmpatil |
last post by:
I am new STL programming.
I have a query regarding vectors. If I am iterating over a vector
using a iterator, but do some operations that modify the size of the
vector. Will the iterator recognize...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
| |