Original Post
🔒 Locked
VC++ 6.0
Advertisement
quote:
Original post by CpMan
you forgot the template parameter for list.
No they didn''t, try clicking on edit, and it''s there.
We can help you, but need to know what errors are you getting? The declaration in itself is fine. Nothing wrong with the code.
Correction:
but
G++, however, compiles the second one just fine IIRC.
I know there are standard compliance issues in VC++ 6.0, and I'd like to find out if I can fix them with a patch or if I have to go get .NET, because I'd like to avoid reinstalling visual studio if I can help it.
[edited by - jbarcz1 on August 30, 2003 6:47:09 PM]
#include <list>
// this will compile
int foo()
{
std::list<int>::iterator foo;
return 0;
}
but
#include <list>
using std::list;
// this will not
int foo()
{
list<int>::iterator foo;
return 0;
}
Errors are:
error C2653: 'list<int,class std::allocator<int> >' : is not a class or namespace name
error C2065: 'iterator' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'foo'
warning C4551: function call missing argument list
G++, however, compiles the second one just fine IIRC.
I know there are standard compliance issues in VC++ 6.0, and I'd like to find out if I can fix them with a patch or if I have to go get .NET, because I'd like to avoid reinstalling visual studio if I can help it.
[edited by - jbarcz1 on August 30, 2003 6:47:09 PM]
It's because list is not a namespace, it's a class. The below should work.
----------------------------------
"English? English? Why would I need to know English? I'm never going to England!"
[edited by - bL0wF1sH on August 30, 2003 9:32:16 PM]
#include <list>
using namespace std;
int foo()
{
list<int>::iterator foo;
return 0;
}
----------------------------------
"English? English? Why would I need to know English? I'm never going to England!"
[edited by - bL0wF1sH on August 30, 2003 9:32:16 PM]
quote:
Original post by bL0wF1sH
It's because list is not a namespace, it's a class. The below should work.
You can "use" classes as well, in fact, it's generally better practice to use a single class than an entire namespace.
jbarcz1 -- your problem has to do with visual C++ 6. It's just a flaw of the compiler. Upgrade to .NET/.NET 2003 or use a different compiler to fix the problem. That, as far as I know, is your only solution without abandoning your current way of tackling the situation.
[edited by - Polymorphic OOP on August 30, 2003 10:19:27 PM]
quote:
Original post by Polymorphic OOPquote:
Original post by bL0wF1sH
It''s because list is not a namespace, it''s a class. The below should work.
You can "use" classes as well, in fact, it''s generally better practice to use a single class than an entire namespace.
jbarcz1 -- your problem has to do with visual C++ 6. It''s just a flaw of the compiler. Upgrade to .NET/.NET 2003 or use a different compiler to fix the problem. That, as far as I know, is your only solution without abandoning your current way of tackling the situation.
[edited by - Polymorphic OOP on August 30, 2003 10:19:27 PM]
Yup, you''re correct. Sorry. I just confused "using" with "using namespace".
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement