赞
踩
①程序与分析
#include <iostream> using namespace std; int a=10;//全局变量 void test() { int a=20;//局部变量 cout<<"局部变量a="<<a<<endl;//优先选择局部变量 //::作用域运算符(C++独有) cout<<"全局变量a="<<::a<<endl;//取全局变量 } int main() { test(); cout<<"全局变量a="<<a<<endl; return 0; }
②运行结果

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。