Topic: Conversion function to base class?
Author: Tom Chatt <tom-chatt@vertel.com>
Date: 1996/08/21 Raw View
Why is it that you can't define conversion functions to
base classes? In the case of protected or private base
classes, the fact of inheritance is invisible to the
interface and exists only to support the implementation.
However, it might be useful to expose a conversion to
the base class as part of the interface. For example,
one might want to specialize a class 'A' by completely
hiding its interface, but still allowing 'B' to be
freely converted to/from an 'A':
class B : private A
{
public:
B(const A&);
operator A(); // why not?
};
It also seems it would be useful for the implementation
to control the behavior of conversion to a multiply-
inherited (non-virtual) base class. For instance:
class B : public A ...
class C : public A ...
class D : public B, public C
{
public:
operator A(); // why not?
};
--
---------------------------------------------------------------
Tom Chatt tom-chatt@vertel.com
Vertel
550 N. Continental Blvd. Voice: 310/606-0800
El Segundo, CA 90245 Fax: 310/335-0186
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]