Error with abs() in c++
<p>Getting error  with abs() function at line 35 in this code. Compiler I choosed : c++(4.3.2)</p>

<p>Look error at bottom.</p>

<pre><code>void bfs(pair&lt;int,int&gt; pixelpos){
bfsq.push(pixelpos);
int u,v,i,j;
pair&lt;int,int&gt; tmpq;
while(!bfsq.empty()){
    tmpq = bfsq.front();
    u = tmpq.first; v = tmpq.second;
    bfsq.pop();
    r(i,u-square_dist,u+square_dist) r(j,v-square_dist,v+square_dist)
      if(inrange(i,j)){
      // ERROR HERE DOWN IN abs() fn
        int dist = abs(pixelpos.first - i) + abs(pixelpos.second -j); // Line: 35
        if(graph[i][j]&gt;dist){
            graph[i][j] = dist;
            bfsq.push(pair&lt;int,int&gt; (i,j));
          }
      }
}
</code></pre>

<p>prog.cpp: In function 'void bfs(std::pair)':</p>

<p><strong>prog.cpp:35: error: call of overloaded 'abs(int)' is ambiguous</strong></p>

<p>/usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)
/usr/include/c++/4.3/cmath:103: note:      float std::abs(float) </p>

<p>/usr/include/c++/4.3/cmath:107: note:      long double std::abs(long double)</p>

<p><strong>prog.cpp:35: error: call of overloaded 'abs(int)' is ambiguous</strong></p>

<p>/usr/include/c++/4.3/cmath:99: note: candidates are: double std::abs(double)</p>

<p>/usr/include/c++/4.3/cmath:103: note:      float std::abs(float)</p>

<p>/usr/include/c++/4.3/cmath:107: note:      long double std::abs(long double)</p>

<p><strong>What might be the reason?</strong></p>