title: why is it giving an error saying " reference to max is ambiguous" in line 12 "if(k>=max)"?
body: <p>here is my function,max is global;</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  int max = 0;
  int q = 0;
  
  int func(int a[], int n)
  {  
       int k = 1;
      for(int j = q + 1; j &lt; n; j++)
      {
          if(a[j] &lt;= a[j - 1])
          {
              if(k &gt;= max)
              {
                  max = k;
                  q = j;
              }
              return 0;
         }
          k++;    
      }
  
      if(k &gt; max)
      {
          max = k;
          return 1;
      }
  }
  </code></pre>
  
  <p>Here it gives the error that it's ambiguous to compare k with max.
  Is it because of max being global?</p>