February 2005
Beginner to intermediate
272 pages
4h 53m
English
Generally, an overriding function must have the same return type as the function it overrides:

However, this rule is relaxed for what are known as “covariant return types.” If B is a class type, and a base class virtual function returns B *, then an overriding derived class function may return D *, where D is publicly derived from B. (That is, D is-a B.) If a base class virtual function returns B &, then an overriding derived class function may return D &. Consider the following clone operation on a shape hierarchy (see Virtual Constructors and Prototype [29, 99]):
The overriding derived class function is declared ...
Read now
Unlock full access