문제

I have something like this

template <class T>
class Outer {
    public: class Inner;

    static Inner* x;

    //...

    class Inner {
        //...
    };
};

// Not working
template <class T>
Outer<T>::Inner* Outer<T>::x = NULL;

Error I get says: :16: error: expected constructor, destructor, or type conversion before ‘*’ token

도움이 되었습니까?

해결책

template<class T>
class Outer {
public: 

    class Inner;

    static Inner* x;

    //...

    class Inner {
        //...
    };
};

template<class T>
typename Outer<T>::Inner *Outer<T>::x = NULL;
  1. As for typename and class, please refer to C++ difference of keywords 'typename' and 'class' in templates

  2. Why this, please refer to Trouble with dependent types in templates

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top