2016-12-05 8 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)에 오류가 있습니다. 템플릿에서 클래스 객체 인스턴스를 어떻게 선언 할 수 있습니까? 어떤 서명이 있어야합니까?템플릿의 정적 클래스 개체

+0

오류 메시지를 보여주지 않았다 – DMaster

답변

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

template < int max > 
Test<max>::global(5);