using std::max

A

Angus

Hello

I am following the exercises in Accelerated C++ Practical Programming by
Example and when use:

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

Is max a fairly new standard library feature? How do I get this to work?

Angus
 
D

Daniel T.

Angus said:
I am following the exercises in Accelerated C++ Practical Programming by
Example and when use:

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

Is max a fairly new standard library feature? How do I get this to work?

It is not "fairly new" is was there when the standard was ratified
AFAIK. Try using a different compiler.
 
I

Ian Collins

Angus said:
Hello

I am following the exercises in Accelerated C++ Practical Programming by
Example and when use:

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

Is max a fairly new standard library feature? How do I get this to work?
No, but VC6 isn't very compliant. Time to upgrade.
 
N

niklasb

AFAIK. Try using a different compiler.

It's true, as others have pointed out, the VC6 was not especially
standards compliant.
(It was after all released before the C++ standard was finalized.)

However, in this particular case, you might want to check if the
problem is a conflict
with another header file. For example, speaking purely hypothetically
(hypotheticals
are always on topic right?), windows.h defines a macro named max. You
can turn this
off by defining the symbol NOMINMAX before you include windows.h.
 
R

red floyd

Angus said:
Hello

I am following the exercises in Accelerated C++ Practical Programming by
Example and when use:

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

Is max a fairly new standard library feature? How do I get this to work?


VC6 is old, it may not be supported.
 
M

Michael

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

I've had troubles where I used std::max, only to figure out I really
needed something like std::max<int>. In particular, the error messages
were cryptic.

Without seeing your code, I don't know whether that might apply or not.

Michael
 
M

Mark P

Angus said:
Hello

I am following the exercises in Accelerated C++ Practical Programming by
Example and when use:

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

Is max a fairly new standard library feature? How do I get this to work?

Angus

Since I don't think anyone else has mentioned it, you should know that
Microsoft now offers free versions of their compilers. Look for Visual
C++ Express Edition. It's much better than VC++ 6.
 
R

Rolf Magnus

Angus said:
Hello

I am following the exercises in Accelerated C++ Practical Programming by
Example and when use:

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

Is max a fairly new standard library feature?

Depends on what you mean by "fairly new". It has been part of standard C++
since the first version of the standard came out in 1998. However, the C++
standard itself is still newer than the compiler you are using.
How do I get this to work?

Well, if everything else fails, you could still define your own max()
template.
 
R

redbox

Hello

I am following the exercises in Accelerated C++ Practical Programming by
Example and when use:

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

Is max a fairly new standard library feature? How do I get this to work?

Angus
ms visual c++ v6 doesn't support std enough;try dev c++,
"free C++ IDE for Windows and Linux for MinGW compiler";
 
M

Marcus Kwok

Angus said:
I am following the exercises in Accelerated C++ Practical Programming by
Example and when use:

using std::max; I get these compile errors in MS Visual C++ v6

error C2039: 'max' : is not a member of 'std'
error C2873: 'max' : symbol cannot be used in a using-declaration

I have #include'd <algorithm> - but cannot see the function declared in
there.

Is max a fairly new standard library feature? How do I get this to work?

IIRC there is a list of workarounds for VC6 on the book's official
website (http://www.acceleratedcpp.com/ but it seems to be down at the
moment). However, as others suggested, I would recommend upgrading your
compiler to something more standards-compliant.
 
A

Angus

Marcus Kwok said:
After further investigation it appears that the domain name may have
expired. Here is a link to Google's cached version (mind the long line):
http://72.14.203.104/search?hl=en&lr=&client=firefox-a&rls=org.mozilla:en-
US%3Aofficial&hs=j93&q=cache%3Ahttp%3A%2F%2Fwww.acceleratedcpp.com%2Fdetails
%2Fmsbugs.html&btnG=Search

The service pack 6 fixed most of it. Plus using some of the workarounds on
the web site you mentioned. Thanks for that. Very helpful.
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top