When is it neccesary to specify std::?

Viewed 107

The following code compiles

#include <cmath>
#include <iostream>

int main()
{
    std::cout << sqrt(4) << std::endl;
}

while this one does not, because cout is missing the std::

#include <cmath>
#include <iostream>

int main()
{
    cout << sqrt(4) << std::endl;
}

why does cout need the std and sqrt does not (even when sqrt is also std::sqrt)?

0 Answers
Related