模糊符号错误?

Hax*_*ify 9 c++ compiler-errors

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;  
    }  
}  
Run Code Online (Sandbox Code Playgroud)

我从来没有得到过这个错误,这令人沮丧.

Fat*_*ror 17

你的变量maxstd::max().尝试使用其他名称,它应该修复该错误.

  • 像这样的原因使`使用命名空间std;`这样的噩梦. (6认同)
  • 而不是重命名`max`我建议不要使用using指令`using namespace std;`正是出于这个原因. (3认同)
  • 或者明确定义max(::max)的命名空间 (2认同)