What is wrong with 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

+6
source share
1 answer

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]; // ^^^^^^^^ 
+9
source

Source: https://habr.com/ru/post/904127/


All Articles