C++中的“和”是什么意思 我知道这在其他地方被问过,但是我找不到它,因为在C++中,操作符和操作符之间的模糊性。我正在学习C++,在HACKEANCH中遇到了一个帮助我混淆的函数。 return x == y and x == ' '
我不确定and是做什么的。用谷歌搜索它只会返回对&operator的引用 整个功能如下;和在第3行:C++中的“和”是什么意思 我知道这在其他地方被问过,但是我找不到它,因为在C++中,操作符和操作符之间的模糊性。我正在学习C++,在HACKEANCH中遇到了一个帮助我混淆的函数。 return x == y and x == ' ',c++,logical-operators,C++,Logical Operators,我不确定and是做什么的。用谷歌搜索它只会返回对&operator的引用 整个功能如下;和在第3行: vector<string> split_string(string input_string) { string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) { return x =
vector<string> split_string(string input_string) {
string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) {
return x == y and x == ' ';
});
input_string.erase(new_end, input_string.end());
while (input_string[input_string.length() - 1] == ' ') {
input_string.pop_back();
}
vector<string> splits;
char delimiter = ' ';
size_t i = 0;
size_t pos = input_string.find(delimiter);
while (pos != string::npos) {
splits.push_back(input_string.substr(i, pos - i));
i = pos + 1;
pos = input_string.find(delimiter, i);
}
splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));
return splits;
}
这些关键字是在开发人员使用不支持&&或| |等字符的键盘时使用的。为这些操作员使用关键字可以解决这个问题 在本例中,与写入&&相同 以下是关键字的完整列表: 及&& 和_eq&= 比特& 比特| 康普~ 不是 不= 或|| 或|= 异或^ xor_方程^= <> >:,是一个不太有名的C++替代运算符,它是一个同义词,因为C/C++代码可以用非ASCII—7字符集/编码文件写入,因此C/C++支持像、、等< /P>操作符的可选命令。 见:
<>编辑:编码问题它们似乎是C++中的关键字,而不是宏。