什么是静态的int类型的和int一个区别? [英] What is the difference between static int a and int a?
本文介绍了什么是静态的int类型的和int一个区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/959889/difference-between-global-and-static-global\">Difference与全球和静态全局
什么是报表1和2之间的区别: -
What is the difference between statements 1 and 2 :-
#include <stdio.h>
//In the global declaration area
static int a; // 1.
int b; // 2.
感谢您的帮助。
推荐答案
A static
global variable is local to the translation unit it is defined in. So, if you define static int a;
in two different translation units, this will create two independent variables. If you define a non-static global variable int b;
in two translation units, you will experience a linker error (but you can use extern int b;
in one of the two translation units to tell the linker that it should use the global variable from the other translation unit).
这篇关于什么是静态的int类型的和int一个区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文