【发布时间】:2011-07-29 04:42:58
【问题描述】:
给定代码:
#include <iostream>
#include <cctype>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s("ABCDEFGHIJKL");
transform(s.begin(),s.end(),s.begin(),tolower);
cout<<s<<endl;
}
我得到错误:
没有匹配函数调用
transform(__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, <unresolved overloaded function type>)
“未解析的重载函数类型”是什么意思?
如果我用我写的函数替换tolower,它就不再出错了。
【问题讨论】:
-
main的返回类型是int,C++ 中的返回类型必须是显式的。一些编译器允许发布的代码,但它是非标准的,它可能会与新的编译器版本或其他编译器中断。 -
@DavidRodríguez-dribeas C 或 C++ 不需要从
main返回,它隐式返回 0。请参阅此答案的 cmets:stackoverflow.com/a/33442842/2642059
标签: c++ compiler-errors lowercase toupper tolower