“OR”令牌之前的预期非限定 ID
expected unqualified-id before ‘or’ token
我在 14 种语言中收到"在'or'令牌之前出现预期的非限定 id"错误C++。我的代码如下:
#include<iostream>
using namespace std;
int main()
{
int s, t, a, b, m, n, count1 = 0, count2 = 0, i;
int ap[100], or[100], ap1[100], or1[100];
cin >> s >> t;
cin >> a >> b;
cin >> m >> n;
for (i = 1; i <= m; i++)
cin >> ap[i];
for (i = 1; i <= n; i++)
cin >> or[i];
for (i = 1; i <= m; i++)
ap1[i] = ap[i] + a;
for (i = 1; i <= n; i++)
or1[i] = or[i] + b;
for (i = 1; i <= m; i++)
if ((ap1[i] >= 7) && (ap1[i] <= 10))
count1++;
for (i = 1; i <= n; i++)
if ((or1[i] >= 7) && (or1[i] <= 10))
count2++;
cout << count1 << endl;
cout << count2 << endl;
return 0;
}
问题是"or"是C++
中的alternative operator
。请参阅:https://en.cppreference.com/w/cpp/language/operator_alternative
您可能会在程序上观察到相同的错误,例如:
int main() {
int or;
}
总之,不要尝试使用and
、or
、not
等关键字作为标识符。(请参阅链接中的完整列表。
相关文章:
- 瓦尔格林德:数学函数"Conditional jump or move depends on uninitialised value(s)"
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- 使用模板进行堆栈实现; "name followed by :: must be a class or namespace"
- 从函数角度看ID到文件路径的内部与外部映射
- 通过组合不同的类型来创建唯一的id
- 我不断收到 [错误] ID 返回 1 退出状态错误,但看不到问题所在
- FFMPEG配置文件级别id大小无效
- 方法内部但循环仍得到预期的不合格id错误C++
- 如何获取 GLFW 窗口 ID?
- Android NDK clang 编译器错误在 Windows 上显示'No such file or directory'
- 当简单捕获中的标识符显示为参数的声明符 ID 时,没有编译器诊断
- 显示数组中的学生 ID 和最高分
- C++:"("令牌"之前有预期的非限定 id 指向类中成员函数的指针
- 在PostgreSQL中根据它们的ID选择大量行的最快方法是什么?
- Xcode 9.4.1 中的 Apple Mach-O 链接器 (id) 错误
- 错误:令牌 { '{' 之前应存在非限定 ID
- 模式"allocate memory or use existing data"
- N-API include an .so or dll
- 已解决 - C++ 的崇高文本中的"fatal error: opencv: no such file or directory"
- “OR”令牌之前的预期非限定 ID