From: Greg C. <chi...@mi...> - 2003-07-18 00:50:13
|
Nicolas Weber wrote: > > template<class Num> > class Matrix44 > { > public: > Matrix44(Num _00, Num _01, Num _02, Num _03, > ..., Num _33); Given the static data member definitions below, you probably intend sixteen arguments here. > static const Matrix44<Num> IDENTITY; > static const Matrix44<Num> ZERO; > > private: > Num m[4][4]; > }; > > Now I want to put the IDENTITY and ZERO definitions outside the class, > what is the right syntax? > > template <class Num> > const Matrix44<Num> Matrix44<Num>::IDENTITY(1, 0, 0, 0, 0, 1, 0, 0, 0, > 0, 1, 0, 0, 0, 0, 1); > > works with gcc 3.3, but it does not with MSVC (MSVC interprets the above > as a function declaration). Now, is this a problem with MSVCs compiler > or is the above syntax wrong? Try it here http://www.comeaucomputing.com/tryitout/ If gcc and comeau agree, then one would suspect that msvc is incorrect, though that's not conclusive. But if the statement above were a declaration of a member function, wouldn't it have to occur inside the class? Ambiguities between declarations and statements are generally resolved as declarations, but I don't see an ambiguity here. If you follow the example in 14.5.1.3, then it's more likely that all compilers will agree. I guess it'd look something like template <class Num> const Matrix44<Num> Matrix44<Num>::ZERO = Matrix44<Num> (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); |