C++.Coding.Standards.1918.Rules.Guidelines [Electronic resources]

Herb Sutter, Andrei Alexandrescu

نسخه متنی -صفحه : 521/ 207
نمايش فراداده

Examples

Example:

Ostrich. If class

Bird defines the virtual function

Fly and you derive a new class

Ostrich (a notoriously flightless bird) from

Bird , how do you implement

Ostrich::Fly ? The answer is, "It depends." If

Bird::Fly guarantees success (i.e., provides the no-fail guarantee; see Item 71) because flying is an essential part of the

Bird model, then

Ostrich is not an adequate implementation of that model.