Skip to main content
gamedev.net
🔒 Locked

VC++ 6.0

Started by jbarcz1 5 replies 1.2k views
Original Post
jbarcz1
jbarcz1
I have Visual Studio 6.0, version: 6.0.8168 (no service packs) The following declaration: std::list::iterator foo; will not compile. Does anyone know if: A) There is a patch to 6.0 that fixes this or B) It is fixed in VC++.NET?
Joshua Barczak3D Application Research GroupAMD
CpMan
CpMan
you forgot the template parameter for list.




VSEDebug Visual Studio.NET Add-In. Enhances debugging in ways never thought possible.
VSEDebug Visual Studio.NET Add-In. Enhances debugging in ways never thought possible.
jamessharpe
jamessharpe
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.
jbarcz1
jbarcz1
Correction:

#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]
Joshua Barczak3D Application Research GroupAMD
bL0wF1sH
bL0wF1sH
It's because list is not a namespace, it's a class. The below should work.


#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]
Jason Olson - Software Developer[ Managed World ]
Polymorphic OOP
Polymorphic OOP
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]
bL0wF1sH
bL0wF1sH
quote:
Original post by Polymorphic OOP
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]


Yup, you''re correct. Sorry. I just confused "using" with "using namespace".
Jason Olson - Software Developer[ Managed World ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.