// This example (part of a series) illustrates how to to use a functor. // // This code explicitly creates a functor object, as opposed to creating // an unnamed temporary. #include #include #include using namespace std; class embiggen { public: char operator()(char c) const { if ('a' <= c && c <= 'z') return c - 'a' + 'A'; else return c; } }; int main() { string name = "Beverly Hills Chihuahua"; transform(name.begin(), name.end(), name.begin(), embiggen()); cout << name << '\n'; }