I have some code (a doubly-linked list implemented as a template) which is generating some bizarre errors.
On Digital Mars C++ (v. 8.42) the code compiles but I have to add what seems to be a superfluous template <typename T> right before the declaration of a friend function to overload <<.
In gcc (via mingw, v.3.4.2), the compiler "suggests" putting a <> after the name of the function to suppress a warning (which seems to cause more trouble). In addition to that I get the following error message.
error: expected constructor, destructor, or type conversion before '*' token
Node is a private class within the DLink2 class.
My questions are: I know that gcc and derivatives are more ISO compliant, but what is it about what I was doing that made a difference? And, is there a way to further resolve the scope for the function definition to recognize the Node type as a return type?
On Digital Mars C++ (v. 8.42) the code compiles but I have to add what seems to be a superfluous template <typename T> right before the declaration of a friend function to overload <<.
Code:
template <typename T> friend std::ostream & operator<<(std::ostream & os, const DLink2<T> * dlink);
Code:
template <typename T> DLink2<T>::Node * DLink2<T>::Link(Node * lastlink,T value,bool before)
Node is a private class within the DLink2 class.
Code:
class DLink2 { private: class Node { private: Node * _pNext; Node * _pPrev; T data; ........etc.
My questions are: I know that gcc and derivatives are more ISO compliant, but what is it about what I was doing that made a difference? And, is there a way to further resolve the scope for the function definition to recognize the Node type as a return type?
Comment