What is the difference between using the std scope resolution for cmath methods and not using it?
#include <cmath>
double a = std::atan(0);
vs.
#include <cmath>
double a = atan(0);
The reason why I ask is because I'm building a custom 'atan' static method, and when calling it from within the static method it obviously clashes with the name of the static method itself. So here I avoid the clash by using 'std::' but it does make me think what is happening below the hood.
Header file:
class MathCustom
{
public:
static double atan(int x, int y);
};
cpp file:
#include <cmath>
double MathCustom::atan(int x, int y)
{
if (x == 0 && y == 0) { return 0; } // undefined angle, but will be set to 0;
if (x == 0) { // y != 0
return (y > 0) ? std::atan(INFINITY) : std::atan(-INFINITY);
} else { // x != 0 && y: any value
return std::atan(static_cast<double>(y) / static_cast<double>(x));
}
}
Appreciated!