Ambiguity error with double as parameter type
For the following code I'm getting the following error: line 15
"Ambiguity between 'std::sqrt(double)' and 'sqrt(double)' in function main()"
I compared the code with my friend's and they were practically identically. Yet, his got no errors. I copied and pasted his code, compiled it, and ran it. It got the same ambiguity error! The assignment itself is just a square root function and that's not the problem. The code is below:
Code:
#include<iostream>
using namespace std;
double sqrt(double x){
double counter = 1;
double guess = 1;
while (counter < 20){
guess = (guess + (x/guess))/2;
counter = counter + 1;
}
return guess;
}
int main(void){
double a;
cin >> a;
cout << sqrt(a);
return 0;
}