Martin
Martin

Reputation: 9369

What is wrong in this template definition?

template <int N>
class myarray {
    typedef int Bitmap;
public:
    static Bitmap data[N];
};

template <int N> myarray<N>::Bitmap myarray<N>::data[N];

error: expected constructor, destructor, or type conversion before ‘myarray’

Upvotes: 6

Views: 101

Answers (1)

Seth Carnegie
Seth Carnegie

Reputation: 75130

You need typename before myarray<N>::Bitmap because it is a dependent type:

template <int N>
class myarray {
    typedef int Bitmap;
public:
    static Bitmap data[N];
};

   template <int N>
   typename myarray<N>::Bitmap myarray<N>::data[N];
// ^^^^^^^^

Upvotes: 9

Related Questions