On Sun, 08 Aug 2004 12:29:21 +0200, Bob Hairgrove
<wouldnt_you_like@to_know.com> wrote:
On Sat, 7 Aug 2004 23:38:14 -0700, "Dave" <be***********@yahoo.com>
wrote:
Hello all,
Quoting from page 24 of "The Boost Graph Library; User Guide and Reference
Manual":
"It turns out that by the contravariance subtyping rule, the parameter type
in the derived classes member function must be either the same type or a
base class of the type as the parameter in the base class."
[snip]
Sorry, it wasn't your proposal ... I got out my copy of the BGL and
looked up the quoted passage. It is confusing to me, too.
In context of what follows (namely, replacing inheritance and virtual
functions with non-member template functions to ensure type safety) I
interpret the quoted passage as a kind of "wishful thinking". The
example given BEFORE the passage illustrates something entirely
different, namely an attempt to use covariant parameter types (which
don't exist in C++ and hence the resulting error message).
But contravariant parameter types, although conceptually feasible,
also don't exist in C++ (yet??). That's the only sense I can make of
it. Note that the second example (ColorPoint2) uses a Point* as
parameter, which is the same type as the base class function "equal()"
takes. It wouldn't work if the derived class took a ColorPoint2* as an
argument (that would be contravariance) because the derived class
equal() would then hide the base class function.
--
Bob Hairgrove
No**********@Home.com