Thread overview |
---|
March 07, 2005 nest template class | ||||
---|---|---|---|---|
| ||||
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 |
April 04, 2005 Re: nest template class | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael | Looks like a compiler bug. I'll take care of it. Thanks, -Walter |
April 08, 2005 Re: Walter "Re: nest template class" - Cross.txt | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Attachments: | 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 |
Copyright © 1999-2021 by the D Language Foundation