#include<iostream> int a = 10; int main() { int i = 10; std::cout<<"a = "<< a<<", i = " << i <<std::endl; int a = 20; //局部变量取代全局变量 std::cout<<"a = "<< a<<", i = " << i <<std::endl; std::cout<<"a = "<< ::a<<", i = " << i <<std::endl; return 0; } 输出结果:a = 10,i = 10; a = 20,i = 10; a= 10,i = 10;
时间: 2024-11-08 11:44:27