|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - 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
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 Apr 08 2005
I've got it fixed now, it'll go out in the next beta. Thanks, -Walter Apr 20 2005
|