Hello everyone.
In the following code, a statement calls function sqrt(), when there are two functions called sqrt(). Is there a rule of "Assume the programmer means the one in the same namespace that we're in", when there's ambiguity? Same for variables, too.
Code:
#include <iostream>
#include <cmath>
using namespace std;
namespace mynmspc
{
double sqrt(double x) { cout << "mynmspc::sqrt()\n"; return 42.0; }
void fn() { cout << sqrt(3.14); } // Which sqrt()?
}
int main()
{
mynmspc::fn();
return 0;
}