0

私はこのようなものを持っています

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;

私が得るエラーは言う::16: error: expected constructor, destructor, or type conversion before ‘*’ token

4

1 に答える 1

1
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

于 2013-04-06T01:51:33.563 に答える