一、大型程序结构控制
(一)extern && static
1.extern
在一个文件中定义了一个东东,想在其他文件中使用
2.static
声明全局静态变量(只能我自己使用,别的文件,不行不行╯︿╰)&局部静态变量(不被重复定义了)
(二)包含头文件
(三)条件编译
优点:
①便于程序移植
②便于调试程序
(四)名字空间
//Xinong.h namespace Xinong { int year=2011; char name[]=“Xinong"; void ShowName() { cout<<name <<" "<< year<<endl; } } //Xilin.h namespace Xilin { int year=2011; char name[]=“Xilin"; void ShowName() { cout<<name <<" "<< year<<endl; } } #include <iostream> using namespace std; #include “Xilin.h“ int main() { Xilin::ShowName(); return 0; }