c++ - nest template class
- Michael (52/52) Mar 07 2005 Hello, I'm a dm user. I run into a problem these days. It may be a simpl...
Hello, I'm a dm user. I run into a problem these days. It may be a simple question in your eyes, but please give me a hand. It's a nest template class question. In VS.net 2003 and gcc, it can be compiled and works well. But in dm errors happen when being compiled. This is what I have done: //in Cross.h template <typename T> class Cross { public: .. class Iterator { public: .. const T& operator*() const; const typename Cross<T>::Iterator operator++(int); //and overload some operators like this }; friend class Iterator; Iterator Row(int m = 0) const; Iterator Row_end() const; protected: .. }; //and in Cross.cpp #include "Cross.h" .. template <typename T> const T& Cross<T>::Iterator::operator*() { .. } template <typename T> const typename Cross<T>::Iterator Cross<T>::Iterator::operator++(int) { .. } //then in main.cpp #include "Cross.cpp" int main() { Cross<int> mat; .. } When compiled: dmc main.cpp it prints errors: template <typename T> ^ Error: 'Iterator' is not a class template
Mar 07 2005
Looks like a compiler bug. I'll take care of it. Thanks, -Walter
Apr 04 2005
I wish my code would help you debug, or you may find that I made the mistake somewhere, not the compiler. P.S It prints: (when meeting any operator overloading from 'operator*' on, but 'operator=' passes successfully) template <typename T> ^ Error: 'Iterator' is not a class template begin 0644 Cross.txt M="!N*3L-" EI;G0 1V5T*&EN="!M+"!I;G0 ;BP 5"8 :71E;2D 8V]N<W0[ M*2!C;VYS=#L-" EI;G0 0V]U;G0H*2!C;VYS=#L- M8V]N<W0 ='EP96YA;64 0W)O<W,\5#XZ.DET97 M<SQ4/CHZ271E<F%T;W( ;W!E<F%T;W(K*RAI;G0I.PT*"0EB;V]L(&]P97)A M=&]R/3TH8V]N<W0 ='EP96YA;64 0W)O<W,\5#XZ.DET97)A=&]R)B!I=&5R M*2!C;VYS=#L-" D)8F]O;"!O<&5R871O<B$]*&-O;G-T('1Y<&5N86UE($-R M;VYS=#L-" D):6YT($-O;" I(&-O;G-T.PT*"7!R;W1E8W1E9#H-" D)8V]N M<W0 0W)O<W,\5#XJ M;VYS=#L-"G!R;W1E8W1E9#H- M;W<L("HJ7W!P0V]L.PT*"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0W)O<W,\5#XZ.DET97)A=&]R($-R;W-S/%0^.CI2;W=?96YD*"D 8V]N M/ T*0W)O<W,\5#XZ.DET97 M/%0^)B!C<F]S<RD-"GL-" E?<$-R;W-S(#T )F-R;W-S.PT*"5]P3F]D92`] M+"!I;G0 ;BD-"GL-" E?<$-R;W-S(#T )F-R;W-S.PT*"5]P3F]D92`](%]P M0W)O<W,M/E]P<%)O=UMM73L-" EW:&EL92`H(%]P3F]D92`F)B!?<$YO9&4M M/F-O;"`A/2!N*0T*"0E?<$YO9&4 /2!?<$YO9&4M/G)O=U]N97AT.PT*?0T* M92!4/ T*8V]N<W0 5"8 0W)O<W,\5#XZ.DET97)A=&]R.CIO<&5R871O<BHH M/ T*8V]N<W0 ='EP96YA;64 0W)O<W,\5#XZ.DET97)A=&]R($-R;W-S/%0^ M<W, )B8 7W!.;V1E*3L-" E)=&5R871O<B!T96UP.PT*"71E;7` /2`J=&AI M<SL-" E?<$YO9&4 /2!?<$YO9&4M/G)O=U]N97AT.PT*"7)E='5R;B!T96UP M.DET97)A=&]R.CIO<&5R871O<CT]*&-O;G-T('1Y<&5N86UE($-R;W-S/%0^ M.CI)=&5R871O<B8 :71E<BD 8V]N<W0-"GL-" ER971U<FX *"!?<$-R;W-S M(#T M871O<CHZ4F]W*"D 8V]N<W0-"GL-" EA<W-E<G0 *%]P0W)O<W, )B8 7W!. M>7!E;F%M92!4/ T*:6YT($-R;W-S/%0^.CI)=&5R871O<CHZ0V]L*"D 8V]N M<W0-"GL-" EA<W-E<G0 *%]P0W)O<W, )B8 7W!.;V1E*3L-" ER971U<FX ` end
Apr 08 2005
I've got it fixed now, it'll go out in the next beta. Thanks, -Walter
Apr 20 2005