AN71

The following code would generate bunch of errors. (try it for your self).

#include <afxdisp.h>
class MyMath {

public:
static double max(double x1, double x2) {
return x1>x2 x1:x2;
}
};
int main()
{
MyMath::max(10,20);
}

The same code will compile if you remove the afxdisp.h or change the function from max to something else.

Does any of you guys seen this and know how to address



Re: Visual C++ General VS60 afxdisp.h and a very simple class causes the compiler to fail with error C2062: type 'double' unexpected

PaulDotNet

Do not write your own "max" function. Either "afxdisp.h" or some of files it includes define max function or macro already.




Re: Visual C++ General VS60 afxdisp.h and a very simple class causes the compiler to fail with error C2062: type 'double' unexpected

AN71

This is not the point. The max function is part of a different class.

Any better ideas





Re: Visual C++ General VS60 afxdisp.h and a very simple class causes the compiler to fail with error C2062: type 'double' unexpected

Simple Samples

max is not a function; it is a macro in the C runtime. Therefore you can't override it as a member function.






Re: Visual C++ General VS60 afxdisp.h and a very simple class causes the compiler to fail with error C2062: type 'double' unexpected

Simple Samples

AN71 wrote:

This is not the point. The max function is part of a different class.

Any better ideas

Look at the documentation.






Re: Visual C++ General VS60 afxdisp.h and a very simple class causes the compiler to fail with error C2062: type 'double' unexpected

AN71

Thanks Sam. You pointed me to the right direction. The macro is defined in windef.h not the c-runtime

This explains why the class would sometime compile...

Thank you!





Re: Visual C++ General VS60 afxdisp.h and a very simple class causes the compiler to fail with error C2062: type 'double' unexpected

AN71

Paul,

I appologize for not seeing through your answer.

Thanks for taking the time.