I have a fairly large application and I am working without the std namespace, I noticed I wasn't including std::cos or std::sin yet I am getting the right results. Why?
An example of some cut down code would be:
#include <ctime>
#include <cmath>
#include <iostream>
#include <vector>
//#include <unistd.h>
#include <fstream>
#include <sstream>
#include <iomanip>
using std::cout;
using std::endl;
int main()
{
double pi = 4*(atan(1));
cout << "pi = " << pi << endl
<< "cos(pi) = " << cos(pi) << endl
<< "sin(pi) = " << sin(pi) << endl;
return 0;
}
I have left all the headers in, I am using them all in the main code. The output returns ~3.14, -1 and 1e-16 as expected. Why does this work? cos and sin are in std aren't they?
I'm using the g++ compiler on a remote unix server
Thanks