|
发表于 2003-8-12 02:21:22
|
显示全部楼层
其实我知道还有个写法跟这个相类似
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <cctype>
- using namespace std;
- int main(void)
- {
- string s = "This is a TEST string.";
- // original
- cout << "orig: " << s << endl;
- // to lower case
- transform (s.begin(), s.end(), s.begin(),
- pointer_to_unary_function<int,int>(tolower));
- cout << "lower: " << s << endl;
- // to upper case
- transform (s.begin(), s.end(), s.begin(),
- pointer_to_unary_function<int,int>(toupper));
- cout << "upper: " << s << endl;
- return 0;
- }
复制代码
也是类型转化,但是不转的话,为什么就不行呢 |
|