?? 20-1.txt
字號:
/* 范例:20-1 */
// 0.0 File scope 開始
#include <iostream.h>
#include <conio.h>
void fun_a(int a,int b); /* 1 函數原型scope(參數行屬于此),其中
a,b的可見度僅限于原型聲明( )內 */
void main(void)
{
int i = 1;
{ // 2.1 區塊scope 開始
cout << i << "\n"; // 輸出main()區塊定義的變量i
int i = 2;
cout << i << "\n"; // 輸出區塊scope(2.1~2.2)內定義的變量i
} // 2.2 區塊scope 結束
if(int m=3) // 3.1 if條件scope 開始
cout << m << "\n"; // 3.2
else
cout << (m+2) << "\n"; // 3.3 if條件scope 結束
cout << "離開while請按Q/q\n";
while(char ch=getch()) // 4.1 while條件scope 開始
{
if((ch=='q')||(ch=='Q'))
break;
putchar(ch);
} // 4.2 while條件scope 結束
switch(char ch=getch()) // 5.1 switch條件scope 開始
{
case 'q':
cout << "switch break!\n";
break;
// case 'q': // Label case 不可重復
default:
cout << "按了" << ch << "\n";
} // 5.2 switch條件scope 結束
KK: // 6 main()中函數scope(Label KK)
cout << "\nKK in main()\n";
fun_a(1,2);
getchar();
}
void fun_a(int a,int b) // 7.1 區塊scope 開始(含參數行)
{
cout << (a+b) << "\n";
KK: // 8 fun_a()中函數scope(Label KK)
cout << "KK in fun_a\n";
} // 7.2 區塊scope 結束
// 0.1 File scope 結束
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -