不提倡使用全局变量

不提倡使用全局变量,尽量不要在头文件中出现象 extern int value 这 类声明。

 1 #include <iostream>
 2 
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 void  disp(void);  //这个函数声明语句不能少
 6 
 7 //定义main()函数的参数和返回值类型是void类型
 8 int main(int argc, char** argv) {
 9     
10      //调用void类型函数
11     disp();  
12     return 0;
13 }
14  
15 //以下定义disp()函数
16 void disp(void)  {
17      cout<<" You are welcome."<<endl;
18 }

 

posted @ 2018-08-03 11:02  borter  阅读(220)  评论(0编辑  收藏  举报