65,186
社区成员




#include "stdafx.h"
#include<iostream>
using std::cout;
using std::endl;
int main()
{
int count1=10;
int count3=50;
cout<<endl
<<"value of outer count1="<<count1
<<endl;
{
int count1=20;
int count2=30;
cout<<"value of inner count1="<<count1
<<endl;
count1 += 3;
count3 += count2;
}
cout<<"value of outer count1="<<count1
<<endl
<<"value of outer count3="<<count3
<<endl;
return 0;
}
这段代码明明给count1进行了自加运算,为什么输出的值还是10,而count3的值却改变了呢。int count1=10;
这段代码定义了变量count1,而后面又接着int count1=20;
int count1
为什么没有报错重复定义