/*プログラマー面接宝典*/Which of the following statements describe the results of executing the code snippet below in C+?

1510 ワード

Which of the following statements describe the results of executing the code snippet below in C++?
1 int i;

2 

3 void main()

4 

5 {

6 

7     int i = i;

8 

9 }

 
    A. The i within main will have an undefined value.
    B. The compiler will allow this statement, but the linker will not be able to resolve the declaration of i.
    C. The i within main will have a value of 1.
    D. The compiler will not allow this statement.
    E. The result is compiler-dependent.
 
役割ドメイン、ストレージタイプ、および接続プロパティに関する問題
1.作用域:内部変数は同名の外部変数を遮断し、
2.第1のiの接続属性はstaticであり、静的記憶領域に記憶され、ファイルの役割ドメインを有する.
2番目のiの接続属性はautoで、スタックストレージ領域に格納され、関数の役割ドメインを有し、
3.接続属性がstatic、すなわち、ストレージタイプが静的ストレージ領域の変数が宣言時に初期化されていない場合、コンパイラはデフォルトで0に初期化します.
接続プロパティはauto、つまりスタックストレージタイプの変数が宣言時に初期化されていない場合、コンパイラは何もしません.この変数ステータスは未定義です.