?? p1-83.txt
字號:
#include<iostream.h>
//聲明全局變量并初始化
extern int a[]={1,2,3};
extern float p=3.14;
//在show()函數中使用外部變量
show() {
int i;
cout<<"In show():"<<endl;
cout<<"p="<<p<<endl;
cout<<"a[]: ";
for (i=0;i<=2;i++)
cout<<a[i]<<" ";
cout<<endl;
//cout<<"y="<<y<<endl; 編譯出錯!
}
//聲明外部變量并初始化
int y=5678;
//在main()函數中使用外部變量
main()
{
//聲明局部變量
int i,p=100;
//顯示重名變量
cout<<"In main():"<<endl;
cout<<"p="<<p<<endl;
//顯示全局變量
cout<<"::p="<<::p<<endl;
cout<<"a[]: ";
for (i=0;i<=2;i++)
cout<<a[i]<<" ";
cout<<endl;
cout<<"y="<<y<<endl; //編譯正確!
show(); //調用函數
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -