transform(mystr.begin(), mystr.end(), mystr.begin(), tolower);
I am using the transform function to make a string all lowercase letters, but even after writing "using namespace std;" at the top of my program I get a whole bunch of errors(when writen like above). When I include the :: operator before the tolower parameter (such as below) I don't. Why is this? I thought the tolower function was in the std namespace and It would work like I have above.
transform(mystr.begin(), mystr.end(), mystr.begin(), ::tolower);
I have the following includes:
#include <iostream>
#include <fstream
#include <sstream>
#include <algorithm>
#include <vector>
In the error message I see:
error: no matching function for call to 'transform(std::basic_string<char>::iterator, ...
then it the place where 'tolower' is in the parameter list
, <unresolved overloaded function type>);'
The
::
is to say it is in the global namespace. It just makes it clear