August 2012
Intermediate to advanced
976 pages
30h 17m
English
The static type (§15.2.3, p. 601) of an object, reference, or pointer determines which members of that object are visible. Even when the static and dynamic types might differ (as can happen when a reference or pointer to a base class is used), the static type determines what members can be used. As an example, we might add a member to the Disc_quote class that returns a pair (§11.2.3, p. 426) holding the minimum (or maximum) quantity and the discounted price:
class Disc_quote : public Quote {public: std::pair<size_t, double> discount_policy() const { return {quantity, discount}; } // other members as before};
We can use discount_policy only through an object, pointer, or reference of type Disc_quote ...
Read now
Unlock full access