Skip to content

Commit

Permalink
refactor 15.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pezy committed Apr 15, 2015
1 parent 9789aa1 commit 586ff0d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 57 deletions.
19 changes: 19 additions & 0 deletions ch15/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,22 @@ class Base { ... };
> Define a class that implements a limited discount strategy, which applies a discount to books purchased up to a given limit. If the number of copies exceeds that limit, the normal price applies to those purchased beyond the limit.
[code](ex15_07_Limit_quote.h)

## Exercise 15.8:
> Define static type and dynamic type.
- static type: Type with which a variable is defined or that an expression yields. Static type is known at **compile time**.

- dynamic type: Type of an object at **run time**. The dynamic type of an object to which a reference refers or to which a pointer points may differ from the static type of the reference or pointer.

## Exercise 15.9:
> When is it possible for an expression’s static type to differ from its dynamic type? Give three examples in which the static and dynamic type differ.
A pointer or reference to a base-class type can refer to an to object of derived type. In such cases the static type is reference (or pointer) to base, but the dynamic type is reference (or pointer) to derived.

Anything like this can be an example.

## Exercise 15.10:
> Recalling the discussion from 8.1 (p. 311), explain how the program on page 317 that passed an `ifstream` to the `Sales_data` `read` function works.
the function takes a `istream` from which `ifstream` is derived. Hence the `ifstream` object "is a" `istream` ,which is why it works.
57 changes: 0 additions & 57 deletions ch15/ex15.8.9.10/ex15.8.9.10.cpp

This file was deleted.

0 comments on commit 586ff0d

Please sign in to comment.