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’
解决方法
你需要在myarray< N> :: Bitmap之前输入typename,因为它是一个依赖类型:
template <int N> class myarray { typedef int Bitmap; public: static Bitmap data[N]; }; template <int N> typename myarray<N>::Bitmap myarray<N>::data[N]; // ^^^^^^^^