码迷,mamicode.com
首页 > 编程语言 > 详细

C++学习笔记(2)作用域

时间:2015-06-18 11:24:54      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

#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;

 

C++学习笔记(2)作用域

标签:

原文地址:http://www.cnblogs.com/Charles-Wang/p/4585151.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!