Почему здесь ошибки?sqrt problem in C++
#include <iostream>
#include <math.h>
#include <vector>
#include <ostream>
using namespace std;
struct Point {
int x,y;
};
int distance (const Point& a,const Point& b){
int k= sqrt(((a.x-b.x)*(a.x-b.x))+((a.y-b.y)*(a.y-b.y)));
}
int main(){
return 0;
}
Сложение выход:
1>------ Build started: Project: distance, Configuration: Debug Win32 ------
1> distance.cpp
1>d:\...\distance.cpp(13): error C2668: 'sqrt' : ambiguous call to overloaded function
1> c:\...\vc\include\math.h(589): could be 'long double sqrt(long double)'
1> c:\...\vc\include\math.h(541): or 'float sqrt(float)'
1> c:\...\vc\include\math.h(127): or 'double sqrt(double)'
1> while trying to match the argument list '(const int)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
'sqrt' _required_, чтобы быть перегруженным для' float', 'long double' и' double' в C++. (См. 26.5 [lib.c.math]) –
... и 'float' не является« еще одним «двойным». – You
@You - это просто двойной, который был на диете. –