静的変数【Static variables】

The memory class of “static” defines a static variable. The specifier “static” is declared before a data type.

“static”のメモリクラスは、静的変数を定義します。データ型の前に”static”と明記すれば宣言できます。

Examples:

例:

 

Static variables are stored in the permanent memory, their values do not get lost when the function is exited. Any variables in a block, except for formal parameters of the function, can be defined as static. The static variable can be initialized by a constant of the corresponded type, unlike a simple local variable which can be initialized by any expression. If there is no explicit initialization, the static variable is initialized with zero. Static variables are initialized only once before calling of the “init()” function, that is at exit from the function inside which the static variable is declared, the value of this variable not getting lost.

静的変数は永続的なメモリに格納されており、関数が終了するときにその値が失われません。仮引数を除く、1ブロック内のどんなパラメータでも、静的変数として定義づけることができます。任意の式で初期化できる単純なローカル変数とは異なり、一致する方の定数で、静的変数を初期化できます。明示的な初期化がない場合は、静的変数はゼロで初期化されます。静的変数は、”init()” を呼び出す前に1度だけ初期化され、静的変数を宣言している関数が終了した後も、変数の値を失いません。

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">