Pergunta

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

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top