Serving the Quantitative Finance Community

 
User avatar
humtumiit
Topic Author
Posts: 0
Joined: April 28th, 2007, 6:20 pm

C++ program

July 24th, 2007, 5:28 pm

I have used algorithm header file. But its not giving output. It's giving one error. I don't know what's the problem. Need help#include <iostream>#include <algorithm>using namespace std;void main(){int a=5,b=-2;int c=max(a,b);cout<< c << endl;}Need help
 
User avatar
simpleshue
Posts: 0
Joined: September 11th, 2006, 1:38 am

C++ program

July 24th, 2007, 7:43 pm

change the "void " into "int"
 
User avatar
lballabio
Posts: 0
Joined: January 19th, 2004, 12:34 pm

C++ program

July 24th, 2007, 7:47 pm

What error?
 
User avatar
humtumiit
Topic Author
Posts: 0
Joined: April 28th, 2007, 6:20 pm

C++ program

July 24th, 2007, 7:50 pm

QuoteOriginally posted by: lballabioWhat error?Thisis the error : error C2065: 'max' : undeclared identifier
 
User avatar
humtumiit
Topic Author
Posts: 0
Joined: April 28th, 2007, 6:20 pm

C++ program

July 24th, 2007, 7:52 pm

QuoteOriginally posted by: simpleshuechange the "void " into "int"if I change void to int error remains same but it gives 1 warning. Problem still exit. int does not sort out problem.
 
User avatar
humtumiit
Topic Author
Posts: 0
Joined: April 28th, 2007, 6:20 pm

C++ program

July 24th, 2007, 8:40 pm

QuoteOriginally posted by: outrunAre you using visual c++? Maybe this:http://support.microsoft.com/default.as ... ;143208Yes m using VC++ 6. with #define NOMINMAX also same problem.
 
User avatar
humtumiit
Topic Author
Posts: 0
Joined: April 28th, 2007, 6:20 pm

C++ program

July 24th, 2007, 9:32 pm

QuoteOriginally posted by: outrunwhat about removing "using namespace std;"and changing toint c = std::max<int>(a,b);That will explicitly call for the STL version of maxIt might be that the STL library of Visual C++ 6 does't implement the max and min like later versions do. In that case you might need to use a STL implementation of a different providor. I've heard about: http://www.stlport.org/No, Still not working. Can you try in your system.
 
User avatar
humtumiit
Topic Author
Posts: 0
Joined: April 28th, 2007, 6:20 pm

C++ program

July 24th, 2007, 9:37 pm

I have seen the command in my original program max() in one book. when i tried in VC++ 6. It doen not work. How is it possible. #include <iostream>#include <algorithm>using namespace std;void main(){int a=5,b=-2;int c=max(a,b);cout << c << endl;}Gives one error ..
 
User avatar
irvingy
Posts: 0
Joined: July 14th, 2002, 3:00 am

C++ program

July 24th, 2007, 11:01 pm

VC++ 6.0 doesn't have min and max in <algorithm>. You need to write your own.
Last edited by irvingy on July 24th, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
mj
Posts: 12
Joined: December 20th, 2001, 12:32 pm

C++ program

July 24th, 2007, 11:11 pm

Try getting the STL from stlport. It's much better than the VC6 STL, which as has already been stated doesn't include min and max.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ program

July 25th, 2007, 5:59 am

VC6 is very old, and isn't really even C++ by any current definition.The STL shit issue MJ highlights is the top of a shitberg with lots more problems waiting to sink your code below the surface.It's 2 versions out of date, and real soon will be 3.You can get a free version of VC++ Express 2005 from MS.
 
User avatar
samyonez
Posts: 0
Joined: October 7th, 2004, 10:01 am

C++ program

July 25th, 2007, 12:16 pm

if you are really forced to use VC6. as i recall it has functions called std::cpp_min and std::cpp_max instead of std::min and std::max, so if you're happy with writing code that will never compile on any other compiler you can use these instead.or you could say...#ifdef MSVC_6#define max cpp_max#define min cpp_min#endifso that it should compile on other systems also; but this is ugly & will probably cause you all sorts of other problems later on. Ideally, just get the 2005 express edition.
Last edited by samyonez on July 24th, 2007, 10:00 pm, edited 1 time in total.