ホーム » VC » コンストラクタで static

コンストラクタで static

次の様なクラスで,VC 14 ではコンストラクタ内の static を呼出した段階で止まってしまう?
VC 12 まででは OK .


  class T_static {
  public:
    T_static () ;
    } ;
  T_static::T_static ()
  {
    {
      static T_static root ;
      }
    std::tout << _T("T_static") << std::endl ;
    }


コンストラクタの初期化動作を次の様に変更.
  T_static::T_static ()
  {
    static bool Initialized = false ;
    if (!Initialized) {
      Initialized = true ;
      static T_static root ;
      }
    std::tout << _T("T_static") << std::endl ;
    }

この投稿は役に立ちましたか ? 0 人中 0 人がこの 投稿 は役に立ったと言っています。

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

© 2009-2026 mish.work All Rights Reserved.

Powered by WordPress / Academica WordPress Theme by WPZOOM