タグ

関連タグで絞り込む (0)

  • 関連タグはありません

タグの絞り込みを解除

programmingとthreadとc++に関するtztのブックマーク (2)

  • 静的変数の初期化 - (void*)Pないと

    http://www.geocities.jp/ky_webid/cpp/language/019.html 静的ローカル変数の初期化についてですが、C言語とは仕様が異なることに注意して下さい。C言語では、静的ローカル変数は、プログラムの実行開始時点で初期化されますが、C++では、通常のローカル変数と同様に、変数定義が記述されているところで初期化されます。そのため次のソースは、C言語ではエラーですが、C++では問題ありません。 void func(int num) { static int snum = num; // C++ではOK。C言語ではエラー } 引数に渡した値によってstaticの値を決定できるということは何か面白そうなものが作れそうな気がしないこともないですね。 いずれにせよC言語とC++との違いとして押さえておきたいです。

    静的変数の初期化 - (void*)Pないと
  • Static (C++)

    The static keyword can be used to declare variables, functions, class data members and class functions. By default, an object or variable that is defined outside all blocks has static duration and external linkage. Static duration means that the object or variable is allocated when the program starts and is deallocated when the program ends. External linkage means that the name of the variable is

    Static (C++)
    tzt
    tzt 2010/02/11
    「Assigning a value to a static local variable in a multithreaded application is not thread safe and we do not recommend it as a programming practice.」CとC++では初期化のタイミングが違う。
  • 1