C语言中数据有两种属性:数据类型和存储类别。数据类型定义了数据格式(长度),存储类别定义了数据的作用域和生命期。
1.变量的声明
1.1
变量的声明的一般形式:存储类别 数据类型 变量名;数据类型以int为例:
作用域:从定义开始到函数结束。
生命期:从函数调用开始到函数推出为止。
定义外部变量:extern int i = 1;或 int i;
1.2
2.static的作用
2.1static作用于变量
2.2static作用于函数
3.C++中的static和unnamed namespace
Unnamed namespace is superior to static keyword, primarily because the keyword static
applies only to the variables declarations and functions, not to the user-defined types.
原文:http://www.cnblogs.com/bukekangli/p/4320223.html