Skip to content

Commit

Permalink
added 9.29 and 9.30
Browse files Browse the repository at this point in the history
  • Loading branch information
pezy committed Dec 2, 2014
1 parent 18743c0 commit 2621431
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ch09/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,19 @@ void insert(forward_list<string> &flst, string find, string insrt)
flst.insert_after(prev, insrt);
}
```
## Exercise 9.29:
>Given that vec holds 25 elements, what does
vec.resize(100) do? What if we next wrote vec.resize(10)?
```cpp
vec.resize(100); // adds 75 elements of value 0 to the back of vec
vec.resize(10); // erases 90 elements from the back of vec
```

## Exercise 9.30:
>What, if any, restrictions does using the version of resize
that takes a single argument place on the element type?

If the container holds elements of a class type and resize adds elements
we **must supply an initializer** or the element type must have a **default constructor**.

0 comments on commit 2621431

Please sign in to comment.