title: C++ collision detection
body: <p>Alright I need to do a collision test.  This way seemed simplest but my compiler doesn't think so.  Thanks for any replies!</p>
  
  <p>C++ Code:</p>
  
  <pre><code>int sqrd(int num) { return (num*num); } //squares a number
  
  bool checkColShip() {
    for(int x = 0;x &lt; 10;x++) {
      double distance = 0; //use to be int tried to change it
      distance = abs( sqrt( sqrd((one.getXPos() - asteroid[x].getXPos()) +
                            sqrd((one.getYPos() - asteroid[x].getYPos()))
                     ); //include cmath
      distance -= 20;//ship radius
      distance -= 20;//asteroid radius
      if (distance&lt;=0) return true;//collision true
    }
    //no collision
    return false;
  }
  </code></pre>
  
  <p>Compiler error:</p>
  
  <pre class="lang-none prettyprint-override"><code>c:\documents and settings\all users\documents\c++ projects\learn sdl\learn sdl\main.cpp(702): error C2668: 'sqrt' : ambiguous call to overloaded function
  c:\program files\microsoft visual studio 10.0\vc\include\math.h(589): could be 'long double sqrt(long double)'
  c:\program files\microsoft visual studio 10.0\vc\include\math.h(541): or       'float sqrt(float)'
  c:\program files\microsoft visual studio 10.0\vc\include\math.h(127): or       'double sqrt(double)'
  while trying to match the argument list '(int)'
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>P.S. I normally indent my code but first time posting here and it kept giving me problems.</p>