Ambiguous symbol error?
39,722
Solution 1
Your variable max
conflicts with std::max()
. Try using a different name and it ought to fix that error.
Solution 2
I think the problem is not std::max()
but these horrible #define's
in minwindef.h
:
#ifndef NOMINMAX
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif /* NOMINMAX */
Use #define NOMINMAX
in your project settings or stdafx.h
.

Author by
Haxify
Updated on September 10, 2020Comments
-
Haxify about 3 years
int ii, maxnum; for(ii=1; ii<=num-1; ii++) { if(count[ii]>max) { // the part where I get C2872 Ambiguous Symbol error max = count[ii]; // the part where I get C2872 Ambiguous Symbol error maxnum = ii; } }
I've never gotten this error and this is frustrating.
-
Andrew Marshall over 11 yearsIt's reasons like this that make
using namespace std;
such a nightmare. -
David Rodríguez - dribeas over 11 yearsRather than renaming
max
I would advice not to use the using directiveusing namespace std;
for exactly this reason. -
outmind over 10 yearsor explicitly define the namespace of max (::max)