【发布时间】:2013-02-24 02:00:58
【问题描述】:
所以我看到了很多类似的问题,但没有一个答案能解决我的问题。有人可以解释为什么这段代码:
string LinkedListByName::toLower(string stringToConvert){
return std::transform(stringToConvert.begin(), stringToConvert.end(), stringToConvert.begin(), ::tolower); }
给我这个错误:
conversion from `__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >' to non-scalar type `std::string' requested
在项目中,我需要将很多字符串转换为低级字符串,而不是升压。我从字面上复制并粘贴了以前运行它的项目中的代码。
另外头文件包括以下内容:
#include <vector>
using namespace std;
#include <iostream>
using namespace std;
#include <string>
using namespace std;
#include <algorithm>
#include "Node.h"
namespace model {
【问题讨论】:
-
using namespace std;几乎在任何时候都是一个坏主意,但这肯定是我第一次看到它连续使用 3 次......