2016-12-05 6 views
-3
template<int max_number> class Test { 

    private: 

    // static object definition 
    static Test Global; 

    public: 

    // constructor 
    Test(int x){ 
    int y; 
    y = x; 
    } 
    //static object definition inside template 
    Test::Global(5); 

    }; 

Test :: Global(5)にエラーがあります。テンプレートでクラスオブジェクトのインスタンスを宣言するにはどうすればよいですか?どのような署名が必要ですか?テンプレート内の静的クラスオブジェクトC++

+0

エラーメッセージが表示されませんでした – DMaster

答えて

0
template < int max > 
struct Test { static Test global; }; 

template < int max > 
Test<max>::global(5); 
関連する問題