小编Aad*_*ish的帖子

什么是"变量'我没有在c ++中声明范围"?

在练习c ++代码时,我使用了for循环中声明的变量.我希望它在另一个for循环中再次使用它.但它向我展示了一个错误

variable i was not declared in scope

我在Eclipse IDE中尝试了相同的循环

the symbol i was not resolved.

示例代码看起来类似于:

 #include<iostream>

    using namespace std;

    int main(){
        for(int i=0;i<10;i++){
            cout<<i;
        }
        for(i=10;i<20;i++){
            cout<<i;
        }
    }
Run Code Online (Sandbox Code Playgroud)

c++ variables scope

4
推荐指数
1
解决办法
2028
查看次数

标签 统计

c++ ×1

scope ×1

variables ×1