I would like to make a function object that converts a string letters to uppercase so that I can pass that functor to transform()
- transform(string.begin(), string.end(), string.begin(), stringToUp());
. I know I can do it otherway, it is just an exercise. Here is my code that works, but my question is why does it work since I pass stringToUp
to transform
without any parameters?
class stringToUp{
public:
int operator()(int ex) {
return toupper(ex); // ??
}
};
int main(){
string k("toupper");
transform(k.begin(), k.end(), k.begin(), stringToUp());
}