“和"是什么时候出现的?成为 C++ 中的运算符

2022-01-23 00:00:00 g++ c++

我有一些看起来像这样的代码:

I have some code that looks like:

static const std::string and(" AND ");

这会导致 g++ 中的错误,如下所示:

This causes an error in g++ like so:

Row.cpp:140: error: expected unqualified-id before '&&' token

所以在诅咒了将和"定义为&&的傻瓜之后,我添加了

so after cursing the fool that defined "and" as &&, I added

#ifdef and
#undef and
#endif

现在我明白了

Row.cpp:9:8: error: "and" cannot be used as a macro name as it is an operator in C++

这导致我的问题是和"何时成为 C++ 中的运算符?我找不到任何表明它的东西,当然除了来自 g++ 的这条消息

Which leads to my question of WHEN did "and" become an operator in C++? I can't find anything that indicates it is, except of course this message from g++

推荐答案

有几个在 C++ 中定义的此类替代方案.您可能可以使用开关来打开/关闭这些.

There are several such alternatives defined in C++. You can probably use switches to turn these on/off.

相关文章