Does Vector is not supported by VC++ 6.0??

R

Ram Laxman

I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;


test.cpp(135) : error C2653: 'std' : is not a class or namespace name
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '<'
error C2653: 'std' : is not a class or namespace name


Does anybody know what is the problem??

Regards
Bubunia
 
J

John Harrison

Ram Laxman said:
I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;


test.cpp(135) : error C2653: 'std' : is not a class or namespace name
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '<'
error C2653: 'std' : is not a class or namespace name


Does anybody know what is the problem??

Regards
Bubunia

vector is supported by VC++6 and your code looks correct. So either the code
you've posted isn't the code you've compiled, or your compiler is installed
incorrectly (perhaps its looking in the wrong places for header files).

john
 
J

Jeff Schwab

Ram said:
I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;


test.cpp(135) : error C2653: 'std' : is not a class or namespace name
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '<'
error C2653: 'std' : is not a class or namespace name


Does anybody know what is the problem??

Try it without "std::".
 
M

Michael Mellor

Ram said:
I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;


test.cpp(135) : error C2653: 'std' : is not a class or namespace name
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '<'
error C2653: 'std' : is not a class or namespace name


Does anybody know what is the problem??

You obviously haven't posted the code that produced the above error so
it will be hard to help you. Have you tried compiling the 6 lines you
have posted by themselves?

Mike
 
M

Michael Groys

Michael said:
You obviously haven't posted the code that produced the above error so
it will be hard to help you. Have you tried compiling the 6 lines you
have posted by themselves?

Mike
 
J

Jacek Dziedzic

U¿ytkownik Ram Laxman napisa³:
I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;


test.cpp(135) : error C2653: 'std' : is not a class or namespace name
error C2143: syntax error : missing ';' before '<'
error C2501: 'vector' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before '<'
error C2653: 'std' : is not a class or namespace name


Does anybody know what is the problem??

That silly "std is not a class or namespace name" error message
reminds me of a situation I had once. I had a missing closing brace
in a header file. Perhaps you're including something that you didn't
show here and this causes the problem? Just an idea.

HTH,
- J.
 
M

Michael Groys

Michael said:
Are you imposing your coding style on the OP? :). The space is perfectly
legal.

Mike
The question is whether it is legal with VC or not.
for example this one:
vector<vector<int>> will not work for sure because of
^^
and the only solution is to write
vector<vector<int>/**/>

Best regards, Michael
 
M

Michael Mellor

Michael said:
The question is whether it is legal with VC or not.
If VC++ 6 does not support the space being there it is well broken but
then again it is at least a 6 year old compiler, I wouldn't dream of
using gcc 2.8 which was released about the same time.
for example this one:
vector<vector<int>> will not work for sure because of
^^
and the only solution is to write
vector<vector<int>/**/>

or if vector< vector<int> > doesn't work:

typedef vector<int> int_vector;
vector<int_vector> obj;

Mike
 
J

Jeff Schwab

Michael said:
The question is whether it is legal with VC or not.
for example this one:
vector<vector<int>> will not work for sure because of
^^
and the only solution is to write
vector<vector<int>/**/>

Doesn't "vector<vector<int> >" work?
 
D

David Harmon

I have used vector in the VC++ compiler. I have included

#include <string>
#include <algorithm>
#include <vector>

std::vector<int> field;
std::vector <int>::size_type i;

Those lines compile with no error using MSVC6 here.

For trouble with your compiler, as opposed to the C++ language issues,
see a newsgroup dedicated to your compiler or platform.
This issue is covered in Marshall Cline's C++ FAQ. It is always good to
check the FAQ before posting. You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/

See the welcome message posted twice per week in comp.lang.c++ or
available at http://www.slack.net/~shiva/welcome.txt
 
D

David Harmon

vector<vector<int>> will not work for sure because of
^^
and the only solution is to write
vector<vector<int>/**/>

Wrong, no space-filling comment required. Standard solution is
vector<vector<int> >

Naturally, operator>> will not work there.
 
M

Michael Groys

David said:
Wrong, no space-filling comment required. Standard solution is
vector<vector<int> >

Naturally, operator>> will not work there.

Just inserting one space doesn't help.
Try it if you don't believe.
 
M

Michael Mellor

Michael said:
Just inserting one space doesn't help.
Try it if you don't believe.

Firstly, I assume your entire discussion is about VC++ 6.

vector<vector<int> > obj;

is the normal way to solve the problem. I couldn't imagine anyone would
write a compiler in which this does not work. Anyhow, you claim that
VC++ 6 does not support the insertion of a space but a quick google
search suggests it does.

Mike
 
E

E. Mark Ping

Just inserting one space doesn't help.
Try it if you don't believe.

You don't know what you're talking about. And you apparently are too
stubborn or arrogant to realize that you might be wrong (and in this
case you *are* wrong).

This is a known ambiguity of the standard, where any
A<B<type> > construct will only compile with the two '>' separated,
typically by whitespace. Refrain from giving advice if your own
ignorance is greater than the OP.
 
D

David Harmon

M

Michael Groys

Michael said:
Firstly, I assume your entire discussion is about VC++ 6.

vector<vector<int> > obj;

is the normal way to solve the problem. I couldn't imagine anyone would
write a compiler in which this does not work. Anyhow, you claim that
VC++ 6 does not support the insertion of a space but a quick google
search suggests it does.

Mike
I didn't do any search in Google concerning this problem, but I did
write programs in VC6 and I got an error.
Did you try it in VC or just in google?
 
P

Pete Becker

E. Mark Ping said:
This is a known ambiguity of the standard, where any
A<B<type> > construct will only compile with the two '>' separated,
typically by whitespace.

It's not an ambiguity. >> is one token, not two.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top