[C++ Error] no matching function for call to 'toupper(__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type&)'

菜鸟一名,求助,百度了这段错误提示,可是没找到答案。请说简单一点,刚学c++没多久。谢谢请输入图片描述

阅读 12k
2 个回答

错误信息很明显,没这个函数。

话说C++里本来就没有toupper(string)这么个函数,C里也没有toupper(char *)这么个函数。你只能一个字符一个字符的用toupper(char)。

我这里看到的错误是

toupper.cc: In function ‘int main()’:
toupper.cc:17: error: cannot convert ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >’ to ‘int’ for argument ‘1’ to ‘int toupper(int)’

http://www.cplusplus.com/reference/cctype/toupper/
从这篇文档看来,toupper应该是C函数,只不过它接受的是int,题主传的是string,所以not match了。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题