Error message: name lookup of ‘jj’ changed for ISO ‘for’ scoping, (if you use ‘-fpermissive’ G++ will accept your code)(错误消息:“jj的名称查找已更改为 ISO“for范围,(如果您使用“-fpermissive,G++ 将接受您的代码))
问题描述
错误是:
In function ‘int returnShortestWeightedBranch(std::vector<route, std::allocator<route> >*)’:
error: name lookup of ‘jj’ changed for ISO ‘for’ scoping
note: (if you use ‘-fpermissive’ G++ will accept your code)
代码是:
for (int i = 0; i< routeVector.size(); i++)
{
if (routeVector[i].exitPoint == exitPointDetailsVector[preserveL].exitPoint)
{
cout << "
-----------parent: " << routeVector[i].exitPoint;
branch obj;
obj.connectedExitPoint = exitPointDetailsVector[preserveI].exitPoint;
routeVector[i].selectedBranchesVector.push_back (obj);
for (int jj = 0; jj < routeVector[i].selectedBranchesVector.size(); jj++);
{
cout << "
-----------branch: " << routeVector[i].selectedBranchesVector[jj].connectedExitPoint;
}
}
}
这里有什么问题?
编辑 1:
我更改了以下内容:
for (int jj = 0; jj < routeVector[i].selectedBranchesVector.size(); jj++);
到:
int jj;
for (jj = 0; jj < routeVector[i].selectedBranchesVector.size(); jj++);
现在它开始工作了!!我不明白原因.
and now it is working!! I fail to understand the REASONS.
推荐答案
在内部 for 语句的末尾有一个分号.jj 的作用域到此结束,所以它在块内不可见.
You have a semicolon at the end of the inner for statement. That ends the scope of jj there, so it is not visible inside the block.
编辑
你已经解决了范围问题,但你的 for 循环仍然只是执行
Edit
You have solved the scope problem, but still have your for loop executing just
<nothing>;
去掉括号后的分号!
这篇关于错误消息:“jj"的名称查找已更改为 ISO“for"范围,(如果您使用“-fpermissive",G++ 将接受您的代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:错误消息:“jj"的名称查找已更改为 ISO“for"范围,(如果您使用“-fpermissive",G++ 将接受您的代码)
基础教程推荐
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- CString 到 char* 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
