Check out the new USENIX Web site. next up previous
Next: Default Arguments Up: Accessory Functions Previous: Function Selection Semantics

Type Casting

The compiler will not produce a virtual argument by applying an implicit type cast to a value (though it may still convert a subclass type reference (or pointer) to a superclass reference (or pointer)). This is an extension of the existing C++ rule that the compiler will not apply an implicit cast to produce the receiver object. Virtual is generally used in the declaration of a pointer or reference type parameter: When applied to the declaration of a value parameter, it affects type casting, but not dispatch (since complete type information must be present at compile time).

The lack of casting for virtual arguments means that adding virtual to a parameter of an existing function may interfere with the compilation of code that had used this function: It may be necessary to add an explicit cast where an implicit one had been used previously to produce the (non-virtual) argument. We believe it would be possible to implement a system that allows implicit casting for accessory functions, but that such a system could produce highly confusing results, as casting is based on the functions that are in scope, but dispatch is based on all compatible functions in the final program.


next up previous
Next: Default Arguments Up: Accessory Functions Previous: Function Selection Semantics

2000-12-09