void countCaps(char c) { if (isupper(c)) capCount++; }
The following example counts the number of capital letters in a string value:
 string advice = "Never Trust Anybody Over 30!";
 for_each(advice.begin(), advice.end(),countCaps);
 cout << "upper-case letter count is " << capCount << endl;