Skip to content

Commit

Permalink
added 14.7
Browse files Browse the repository at this point in the history
  • Loading branch information
pezy committed Apr 7, 2015
1 parent 66ceeb5 commit 361a3b1
Show file tree
Hide file tree
Showing 26 changed files with 620 additions and 2,319 deletions.
6 changes: 3 additions & 3 deletions ch13/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ when we copy a `StrBlobPrts`, the `weak_ptr` member's use_count isn't changed.(c
>Assuming Point is a class type with a public copy constructor, identify each use of the copy constructor in this program fragment:
```cpp
Point global;
Point foo_bar(Point arg) // 1. Pass an object as an argument to a parameter of nonreference type
Point foo_bar(Point arg)
{
Point local = arg, *heap = new Point(global); // 2.3. copy initialization
*heap = local; // 4. Define variables using an `=`
Point local = arg, *heap = new Point(global); // copy constructor
*heap = local;
Point pa[ 4 ] = { local, *heap }; // 5. Brace initialize the elements in an array
return *heap; // 6. Return an object from a function that has a nonreference return type
}
Expand Down
16 changes: 16 additions & 0 deletions ch14/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,19 @@ see [Exercise 14.27](#exercise-1427)
> We did not define a `const` version of the increment and decrement operators. Why not?
Because `++` and `--` change the state of the object. Hence ,it's meaningless to do so.

## Exercise 14.30:
> Add dereference and arrow operators to your `StrBlobPtr` class and to the `ConstStrBlobPtr` class that you defined in exercise 12.22 from 12.1.6 (p. 476). Note that the operators in `constStrBlobPtr` must return `const` references because the `data` member in `constStrBlobPtr` points to a `const vector`.
[hpp](ex14_30_StrBlob.h) | [cpp](ex14_30_StrBlob.cpp) | [Test](ex14_30_StrBlobTest.cpp)

## Exercise 14.31:
> Our StrBlobPtr class does not define the copy constructor, assignment operator, or a destructor. Why is that okay?
Applying the Rule of 3/5:
There is no dynamic allocation to deal with, so the synthesized destructor is enough. Moreover, no unique is needed. Hence, the synthesized ones can handle all the corresponding operations.

## Exercise 14.32:
> Define a class that holds a pointer to a `StrBlobPtr`. Define the overloaded arrow operator for that class.
[hpp](ex14_32.h) | [cpp](ex14_32.cpp)
28 changes: 0 additions & 28 deletions ch14/ex14.30.31.32/CppPrimer.pro

This file was deleted.

155 changes: 0 additions & 155 deletions ch14/ex14.30.31.32/Sales_data.cc

This file was deleted.

118 changes: 0 additions & 118 deletions ch14/ex14.30.31.32/Sales_data.h

This file was deleted.

Loading

0 comments on commit 361a3b1

Please sign in to comment.