[comp.lang.c++] function matching, standard conversion, class hierarchy

stanl@cbnewsm.ATT.COM (stanley.b.lippman) (10/19/89)

Desmond D'Souza write:

>>When resolving an overloaded function, based on Lippman, p 160:
>>	"Closeness of type is not considered."
>>it seems that the number of type conversions required for a match is
>>not considered in resolving a call. I understand this as a safety
>>feature with silent built-in conversions. However, I dont think it
>>fits in well with class derivation, as the philosophy and purpose of
>>automatic conversions in a type hierarchy is QUITE different. Maybe the
>>2 kinds of conversions should be distinguished? I hear "aargh!"s, but 
>>think about it for a minute. Here is an example:

The discussion of function matching presented in chapter 4 is limited
to the built-in (and derived data types, such as arrays).  Function
matching is revisted in Chapter 8, following the introduction of 
class inheritance, where, on page 333, I note, with regard to standard
conversion:

``A derived class is considered more nearly the type of its
immediate base class than of a base class further removed.
The following call is not ambiguous although a standard conversion
is required is both instances.  A Panda is treated as being more
nearly a kind of Bear than a kind of ZooAnimal by the argument-matching
algorithm.''

Jonathan Shopiro was the individual who originally argued for this
handling of the class hierarchy, pointing out its orthogonality to
the resolution of virtual function calls.

stan lippman
at&t bell laboratories
stan@mozart.att.com