错误消息:'jj'的名称查找已更改为ISO'为'范围,(如果使用'-fpermissive'G ++将接受您的代码) [英] Error message: name lookup of ‘jj’ changed for ISO ‘for’ scoping, (if you use ‘-fpermissive’ G++ will accept your code)

查看:4891
本文介绍了错误消息:'jj'的名称查找已更改为ISO'为'范围,(如果使用'-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 << "\n-----------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 << "\n-----------branch: " << routeVector[i].selectedBranchesVector[jj].connectedExitPoint;
                }
            }
        }

编辑1:

EDIT 1:

for (int jj = 0; jj < routeVector[i].selectedBranchesVector.size(); jj++);

到:

int jj;
for (jj = 0; jj < routeVector[i].selectedBranchesVector.size(); jj++);

现在它正在工作!我不明白REASONS。

and now it is working!! I fail to understand the REASONS.

推荐答案

在inner 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>;

删除圆括号后面的分号!

Remove the semicolon after the parenthesis!

这篇关于错误消息:'jj'的名称查找已更改为ISO'为'范围,(如果使用'-fpermissive'G ++将接受您的代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆