| | | | Browse by category |
Article ID: 1067
Last updated: 05 Feb, 2008
Problem
I try to create a list of lists like this: RWTPtrDlist<RWTPtrDlist > xyz; but the compiler responds with errors indicating problems with
Cause
Any type used to parameterize RWTPtrDlist (and RWTValDlist, RWTPtrSlist and RWTValSlist as well) must have an
Action
The solution is to derive from the list class and provide an
I try to create a list of lists like this: RWTPtrDlist
operator==
.
Cause
Any type used to parameterize RWTPtrDlist (and RWTValDlist, RWTPtrSlist and RWTValSlist as well) must have an
operator==
defined: int T::operator == (const T&) const. The class RWTPtrDlist (and RWTValDlist, etc) does not implement the ==
operator, thus parameterizing RWTPtrDlist with another may cause compiler errors. Some compilers insist on having a matching definition for every declaration in a templatized class, even if the method or operator is never used. Other compilers will ignore the lack of implementation and compile the code successfully.Action
The solution is to derive from the list class and provide an
==
operator:
templateand then create the list of lists:class Dlist : public RWTPtrDlist
{
public:
int operator == (const T& list) const
{ return 0; }
};
RWTPtrDlist< Dlistor> xyz;
RWTValDlist< Dlist> xyz;
The return value from Dlist
can be constant as it is above, or you can fully implement the test for equality if you wish.
This article was:
Helpful |
Not helpful
Report an issue
Article ID: 1067
Last updated: 05 Feb, 2008
Revision: 1
Views: 3031
Posted: 24 Sep, 1997 by
Dean J.
Updated: 05 Feb, 2008 by
Dean J.
Others in this category
Powered by KBPublisher (Knowledge base software)