Thread overview
nest template class
Mar 07, 2005
Michael
Apr 04, 2005
Walter
Re: Walter "Re: nest template class" - Cross.txt
Apr 08, 2005
Michaelgs
Apr 20, 2005
Walter
March 07, 2005
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
Looks like a compiler bug. I'll take care of it. Thanks, -Walter


April 08, 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


April 20, 2005
I've got it fixed now, it'll go out in the next beta. Thanks, -Walter