加文

希望是美好的……
随笔 - 0, 文章 - 209, 评论 - 0, 引用 - 0
数据加载中……

作用域问题

变量是否为const变量,没有影响。
/*

* main.cpp
*/
#include <string>
#include <iostream>
using namespace std;
extern int a ;
void show();
int main()
{
    cout<<a<<endl;
    show();
    getchar();
    return 0;
}

int a = 10;


/*
* test.cpp
*/
#include <iostream>
extern int a ;
void show()
{
    a  = 210;
    std::cout<<a<<std::endl;
}

posted on 2012-03-26 17:51 加文 阅读(69) 评论(0)  编辑 收藏 引用 所属分类: C++


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理