【发布时间】:2013-05-28 12:46:14
【问题描述】:
谁能告诉我这个程序的错误是什么
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
string str = "Now";
transform(str.begin(), str.end(), str.begin(), toupper);
cout<<str;
return 0;
}
错误:
"no matching function for call to '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>)'
compilation terminated due to -Wfatal-errors."
【问题讨论】:
-
试试
..., ::toupper); -
尝试
#include <locale>然后std::ctype::toupper作为参数。 -
当您处理无法弄清楚的错误时,不使用
-Wfatal-errors进行编译可能会有所帮助,因为该开关会抑制相关信息。
标签: c++